Skip to content

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.

1.3 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0

// Per account, like history: one account's "Always allow" must not skip another's prompt.

import { create } from "zustand";
import { createJSONStorage, persist } from "zustand/middleware";
import { accountDatabaseName } from "@/lib/account-transition";
import { syncAcrossWindows } from "@/lib/sync-across-windows";

/** "allowAll": files that can run programs too, which "allow" still asks about. */
export type DownloadSiteDecision = "allow" | "allowAll" | "block";

interface DownloadSitesState {
  sites: Record<string, DownloadSiteDecision>;
  setSite: (origin: string, decision: DownloadSiteDecision | null) => void;
}

export const useDownloadSitesStore = create<DownloadSitesState>()(
  persist(
    (set) => ({
      sites: {},
      setSite: (origin, decision) =>
        set((state) => {
          const sites = { ...state.sites };
          if (decision) sites[origin] = decision;
          else delete sites[origin];
          return { sites };
        }),
    }),
    {
      name: accountDatabaseName("unsloth_browser_download_sites"),
      version: 1,
      storage: createJSONStorage(() => localStorage),
    },
  ),
);
syncAcrossWindows(useDownloadSitesStore);