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 { LazyImportBoundary } from "@/components/lazy-import-boundary";
import { Button } from "@/components/ui/button";
import { toast } from "@/lib/toast";
import { Share01Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import { type ComponentProps, Suspense, lazy, useLayoutEffect } from "react";
import type { ModelPickTarget } from "../components/model-selector/types";
import {
isExtraArgsHydratedForDraft,
modelConfigDraftKey,
} from "../model-config/model-config-draft";
import { runConfigInbox } from "./inbox";
import { isRunConfigVariantUnresolved } from "./target";
const SharedRunConfigActions = lazy(() =>
import("./config-ui").then((module) => ({
default: module.SharedRunConfigActions,
})),
);
const ConfigReview = lazy(() =>
import("./config-ui").then((module) => ({
default: module.SharedRunConfigReview,
})),
);
export function isRunConfigEditorChange(event: {
currentTarget: Node;
target: EventTarget;
}): boolean {
return (
event.target instanceof Node && event.currentTarget.contains(event.target)
);
}
export function SharedRunConfigReview({
target,
...props
}: ComponentProps<typeof ConfigReview> & { target: ModelPickTarget }) {
return (
<>
{props.imported && (
<LazyImportBoundary
fallback={
<p role="alert" className="mb-5 text-ui-12 text-muted-foreground">
The link settings summary could not load. Reload Unsloth and
reopen the link to review it.
</p>
}
>
<Suspense fallback={null}>
<ConfigReview {...props} />
</Suspense>
</LazyImportBoundary>
)}
{isRunConfigVariantUnresolved(target) && (
<p
role="status"
className="mb-5 border-b border-border pb-5 text-pretty text-ui-12 leading-relaxed text-muted-foreground"
>
The GGUF variant could not be resolved. You can edit and share these
settings offline. Reopen the link when the Hugging Face model is
accessible before loading. To keep any edits, copy a new link with
Share first.
</p>
)}
</>
);
}
export function SharedRunConfigControls({
isDiffusion,
...props
}: Omit<
ComponentProps<typeof SharedRunConfigActions>,
"hydrated" | "draftKey"
> & {
isDiffusion: boolean;
}) {
const { target, canImport } = props;
const key = modelConfigDraftKey(
target.configId ?? target.id,
target.ggufVariant,
);
useLayoutEffect(() => {
if (canImport) {
return runConfigInbox.retainEditor(key, (request) => {
toast.info("Run settings import cancelled", {
id: request.id,
description:
"The editor closed before the settings were imported. Reopen the link to try again.",
});
});
}
}, [canImport, key]);
const fallback = (
<Button
type="button"
size="icon-sm"
variant="outline"
className={props.className}
aria-label="Share"
title="Share"
disabled
>
<HugeiconsIcon
icon={Share01Icon}
strokeWidth={1.75}
className="size-[calc(1rem*var(--ui-space-scale,1))]"
/>
</Button>
);
return (
<LazyImportBoundary fallback={fallback}>
<Suspense fallback={fallback}>
<SharedRunConfigActions
{...props}
draftKey={key}
hydrated={isDiffusion || isExtraArgsHydratedForDraft(key)}
/>
</Suspense>
</LazyImportBoundary>
);
}