Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
import {
ContextMenu,
ContextMenuContent,
ContextMenuItem,
ContextMenuSeparator,
ContextMenuTrigger,
} from "@/components/ui/context-menu";
import { useT } from "@/i18n";
import { copyToClipboard } from "@/lib/copy-to-clipboard";
import { openExternalLink } from "@/lib/open-link";
import { toast } from "@/lib/toast";
import {
ArrowUpRight01Icon,
LinkSquare02Icon,
PlusSignIcon,
} from "@hugeicons/core-free-icons";
import { Copy01Icon } from "@/lib/copy-icon";
import { HugeiconsIcon, type IconSvgElement } from "@hugeicons/react";
import type { ReactElement, ReactNode } from "react";
import { useBrowserStore } from "./store";
export const CONTEXT_MENU = "browser-menu unsloth-plus-menu sidebar-row-menu w-56";
const MENU_ICON = "size-icon";
export function MenuRow({
icon,
children,
onSelect,
destructive,
}: {
icon: IconSvgElement;
children: ReactNode;
onSelect: () => void;
destructive?: boolean;
}) {
return (
<ContextMenuItem
onSelect={onSelect}
variant={destructive ? "destructive" : "default"}
>
<HugeiconsIcon icon={icon} strokeWidth={1.75} className={MENU_ICON} />
{children}
</ContextMenuItem>
);
}
export function LinkContextMenu({
url,
tabId,
extra,
onCloseAutoFocus,
children,
}: {
url: string | null;
tabId?: string;
extra?: ReactNode;
onCloseAutoFocus?: (event: Event) => void;
children: ReactElement;
}) {
const t = useT();
const { navigate, openUrl } = useBrowserStore.getState();
return (
<ContextMenu>
<ContextMenuTrigger asChild={true}>{children}</ContextMenuTrigger>
<ContextMenuContent className={CONTEXT_MENU} onCloseAutoFocus={onCloseAutoFocus}>
{url ? (
<>
{tabId ? (
<MenuRow
icon={ArrowUpRight01Icon}
onSelect={() => navigate(tabId, { url })}
>
{t("browser.suggestedMenu.open")}
</MenuRow>
) : null}
<MenuRow
icon={PlusSignIcon}
onSelect={() => openUrl(url, { newTab: true })}
>
{t("browser.suggestedMenu.openInNewTab")}
</MenuRow>
<MenuRow
icon={LinkSquare02Icon}
onSelect={() => openExternalLink(url)}
>
{t("browser.openExternal")}
</MenuRow>
<ContextMenuSeparator />
<MenuRow
icon={Copy01Icon}
onSelect={() =>
void copyToClipboard(url).then(
(ok) => ok && toast.success(t("browser.linkCopied")),
)
}
>
{t("browser.copyLink")}
</MenuRow>
{extra ? <ContextMenuSeparator /> : null}
</>
) : null}
{extra}
</ContextMenuContent>
</ContextMenu>
);
}