/* Copyright 2026 Marimo. All rights reserved. */
import { useRestartKernel } from "@/components/editor/actions/useRestartKernel";
import { Kbd } from "@/components/ui/kbd";
import { ToastAction } from "@/components/ui/toast";
import { toast } from "@/components/ui/use-toast";
export const RESTART_REQUIRED_DESCRIPTION =
"Your dependency changes are saved. Restart the kernel to use the updated environment. Restarting clears in-memory variables.";
const RestartKernelAction = () => {
const restartKernel = useRestartKernel();
return (
Restart Kernel
);
};
export const showPackageRestartToast = () => {
toast({
title: "Changes saved — restart required",
description: RESTART_REQUIRED_DESCRIPTION,
duration: Infinity,
action: ,
});
};
export const showSandboxSyncToast = () => {
toast({
title: "Sandbox environment synced",
description: (
Some Python packages may require a kernel restart to see changes.
),
});
};
export const showAddPackageToast = (
packageName: string | string[],
error?: string | null,
) => {
const packageNames = Array.isArray(packageName) ? packageName : [packageName];
if (error) {
toast({
title:
packageNames.length > 1
? "Failed to add packages"
: "Failed to add package",
description: error,
variant: "danger",
});
} else {
toast({
title: packageNames.length > 1 ? "Packages added" : "Package added",
description: (
{packageNames.length > 1 ? "The packages " : "The package "}
{packageNames.map((name, index) => (
{index > 0 && ", "}
{name}
))}{" "}
and {packageNames.length > 1 ? "their" : "its"} dependencies have
been added to your environment.
Some Python packages may require a kernel restart to see changes.
),
});
}
};
export const showUpgradePackageToast = (
packageName: string,
error?: string | null,
) => {
if (error) {
toast({
title: "Failed to upgrade package",
description: error,
variant: "danger",
});
} else {
toast({
title: "Package upgraded",
description: (
The package {packageName} has been
upgraded.
Some Python packages may require a kernel restart to see changes.
),
});
}
};
export const showRemovePackageToast = (
packageName: string,
error?: string | null,
) => {
if (error) {
toast({
title: "Failed to remove package",
description: error,
variant: "danger",
});
} else {
toast({
title: "Package removed",
description: (
The package {packageName} has been
removed from your environment.
Some Python packages may require a kernel restart to see changes.
),
});
}
};