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.

22.1 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

import type { TranslationKey } from "@/i18n";
import type { HubSource } from "@/lib/hf-endpoint";
import type { SettingsTab } from "./stores/settings-dialog-store";

/** Tab names always match, so tabs without translatable rows stay reachable. */
export const SETTINGS_SEARCH_INDEX: Record<SettingsTab, TranslationKey[]> = {
  accounts: [
    "settings.accounts.title",
    "settings.accounts.create",
    "settings.general.managedProviderUrls.sectionTitle",
    "settings.general.managedProviderUrls.enableLabel",
  ],
  general: [
    "settings.general.account",
    "settings.general.password",
    "settings.general.huggingFaceToken",
    "settings.appearance.language.title",
    "settings.appearance.language.label",
    "settings.appearance.language.spellCheck",
    "settings.general.display.title",
    "settings.general.display.timeFormat",
    "settings.general.notifications.sectionTitle",
    "settings.general.notifications.showLoadedModels",
    "settings.general.notifications.updateReminders",
    "settings.general.previewSharing.sectionTitle",
    "settings.general.previewSharing.enableLabel",
    "settings.general.previewSharing.revokeLabel",
    "settings.general.rag.sectionTitle",
    "settings.general.rag.embeddingModel",
    "settings.general.mlWarmup.sectionTitle",
    "settings.general.mlWarmup.hardwareLabel",
    "settings.general.mlWarmup.textLabel",
    "settings.general.mlWarmup.datasetsLabel",
    "settings.general.mlWarmup.mediaLabel",
    "settings.general.mlWarmup.quantizationLabel",
    "settings.general.helperLlm.sectionTitle",
    "settings.general.helperLlm.preloadOnStartup",
    "settings.general.hub.sectionTitle",
    "settings.general.hub.source",
    "settings.general.hub.endpoint",
    "settings.general.hub.datasetsServer",
    "settings.general.downloads.sectionTitle",
    "settings.general.downloads.transport",
    "settings.general.downloads.https",
    "settings.general.downloads.xet",
    "settings.general.downloads.auto",
    "settings.general.uploads.sectionTitle",
    "settings.general.uploads.maxUploadSize",
    "settings.general.resetPreferences.sectionTitle",
    "settings.general.resetPreferences.label",
  ],
  profile: [
    "settings.profile.title",
    "settings.profile.description",
    "settings.profile.displayName",
    "settings.profile.nickname",
    // Only always-rendered labels: the avatarShape popover and conditional cards have no anchor.
    "settings.profile.stats.title",
    "settings.profile.stats.lifetimeTokens",
    "settings.profile.stats.peakTokens",
    "settings.profile.stats.longestChat",
    "settings.profile.stats.currentStreak",
    "settings.profile.stats.longestStreak",
  ],
  appearance: [
    "chatBackground.title",
    "chatBackground.material",
    "chatBackground.glassTheme",
    "chatBackground.materialStyle",
    "chatBackground.materialMenus",
    "chatBackground.materialStrength",
    "chatBackground.lens",
    "chatBackground.fade",
    "chatBackground.sizingPosition",
    "chatBackground.zoom",
    "chatBackground.effect",
    "chatBackground.visibility",
    "chatBackground.blur",
    "settings.appearance.theme.label",
    "settings.appearance.palette.label",
    "settings.appearance.custom.colors.accent",
    "settings.appearance.custom.colors.background",
    "settings.appearance.custom.colors.foreground",
    "settings.appearance.custom.uiFont.label",
    "settings.appearance.custom.headingFont.label",
    "settings.appearance.custom.chatFont.label",
    "settings.appearance.custom.chatWidth.label",
    "settings.profile.greetingSloth",
    "settings.appearance.composer.title",
    "settings.chat.composerPosition",
    "chatBackground.outline",
    "settings.appearance.custom.sentAttachments.label",
    "settings.appearance.code.title",
    "settings.appearance.custom.codeFont.label",
    "settings.appearance.code.lineNumbers.label",
    "settings.appearance.code.wordWrap.label",
    "settings.appearance.code.ligatures.label",
    "settings.appearance.custom.contrast.label",
    "settings.appearance.custom.pointerCursors.label",
    "settings.appearance.custom.reduceMotion.label",
    "settings.appearance.custom.uiFontSize.label",
    "settings.appearance.custom.interfaceScale.label",
    "settings.appearance.custom.elementOutline.label",
    "settings.appearance.custom.codeFontSize.label",
    "settings.appearance.custom.fontSmoothing.label",
    "settings.appearance.layout.compactSidebar",
    "settings.appearance.sidebarNav.title",
    "settings.appearance.sidebarMenu.title",
    "settings.appearance.sidebarMenu.darkModeToggle",
  ],
  resources: [
    "settings.resources.liveMonitor.title",
    "settings.resources.liveMonitor.cpu",
    "settings.resources.liveMonitor.ram",
    "settings.resources.liveMonitor.vram",
    "settings.resources.liveMonitor.disk",
    "settings.resources.liveMonitor.refreshRate",
    "settings.resources.liveMonitor.unslothShare",
    "settings.resources.liveMonitor.modelBreakdown",
    "settings.resources.gpu.title",
    "settings.resources.modelMemory.title",
    "settings.resources.modelMemory.keepResident",
    "settings.resources.modelMemory.noRamReserve",
    "settings.resources.modelMemory.multiModel",
    "settings.general.modelAutoSwitch.mediaIdleUnload",
    "settings.resources.storage.title",
    "settings.resources.storage.modelsFolder",
    "settings.resources.storage.futureDownloads",
    "settings.resources.storage.systemDisk",
    "settings.resources.storage.caches.label",
    "settings.resources.environment.title",
    "settings.resources.environment.backend",
    "settings.resources.environment.python",
    "settings.resources.environment.torch",
    "settings.resources.environment.transformers",
    "settings.resources.liveUpdates",
    "settings.about.engines.title",
    "settings.general.developerMode.sectionTitle",
    "settings.general.developerMode.videoCpu",
  ],
  chat: [
    "settings.general.chatDefaults",
    "composerSettings.sendShortcut",
    "composerSettings.followUp",
    "composerSettings.plainText",
    "composerSettings.richPaste",
    "composerSettings.showContext",
    "settings.chat.pastedTextThreshold",
    "settings.chat.turnNavigation",
    "settings.chat.groups.conversations.title",
    "settings.chat.groups.replies.title",
    "settings.chat.groups.thinkingTools.title",
    "settings.chat.library.label",
    "settings.chat.groups.display.title",
    "settings.chat.modelSelection.title",
    "settings.chat.modelSelection.fitOnDeviceOnly",
    "settings.chat.currentDate.label",
    "settings.chat.memory.title",
    "settings.chat.memory.enable",
    "settings.general.autoTitleNewChats",
    "settings.chat.projectAttachments",
    "settings.chat.rememberParamsPerModel",
    "settings.chat.autoCompact",
    "settings.chat.keepRunningWhenTabClosed",
    "settings.chat.toolResultLimit",
    "settings.chat.firstTokenLabel",
    "settings.chat.autoScroll",
    "settings.chat.replyNotification",
    "settings.chat.thinking.visibility",
    "settings.chat.tools.visibility",
    "settings.chat.tools.foldIntoThinking",
    "settings.chat.webSearch.images",
    "settings.chat.showLinkPreviews",
    "settings.chat.inlineEditResponse",
    "settings.chat.showReplyTimes",
    "settings.chat.showGenerationDetails",
    "settings.chat.generationStatsUpdates",
    "settings.chat.groups.menu.title",
  ],
  browser: [
    "browser.agentSettings.title",
    "browser.agentSettings.enable",
    "browser.agentSettings.history",
    "browser.agentSettings.scripts",
    "browser.agentSettings.cursor",
    "browser.agentSettings.permissionsTitle",
    "browser.linksTitle",
    "browser.openLinksSetting",
    "browser.openFilesSetting",
    "settings.chat.artifacts.title",
    "settings.chat.artifacts.collapseHtmlBlocks",
    "settings.chat.artifacts.allowNetworkAccess",
    "browser.tabsTitle",
    "browser.switchToNewTabsSetting",
    "browser.defaultZoomSetting",
    "browser.addressBarTitle",
    "browser.searchEngineSetting",
    "browser.showFullUrlSetting",
    "browser.newTabPageTitle",
    "browser.showSuggestedSetting",
    "browser.showRecentsSetting",
    "browser.hiddenSuggestionsSetting",
    "browser.bookmarksTitle",
    "browser.bookmarksToolbarSetting",
    "browser.bookmarks.showEditor",
    "browser.importBookmarksSetting",
    "browser.downloadsTitle",
    "browser.askWhereToSaveSetting",
    "browser.askBeforeDownloadingSetting",
    "browser.askBeforeProgramDownloadsSetting",
    "browser.downloadSitesSetting",
    "browser.saveDownloadHistorySetting",
    "browser.browsingDataTitle",
    "browser.saveHistorySetting",
    "browser.historyRetentionSetting",
    "browser.historySetting",
    "browser.downloadsSetting",
    "browser.clearDataSetting",
    "browser.annotationsTitle",
    "browser.annotationScreenshotsSetting",
  ],
  library: [
    "settings.library.storageSection",
    "settings.library.locationsSection",
    "settings.library.cardSize",
    "settings.library.imageLayout",
    "settings.library.showCardDates",
    "settings.library.imageInfoStamp",
    "settings.library.startTab",
    "settings.library.sort",
    "settings.library.suggestedLimit",
    "settings.library.tabsSection",
    "settings.library.contentSection",
    "settings.library.showChatAttachments",
    "settings.library.showChatToolFiles",
    "settings.library.showGeneratedMedia",
    "settings.library.categoryFineTunes",
    "settings.library.confirmDelete",
    "settings.library.reset",
  ],
  data: [
    "settings.data.manageFiles.label",
    "settings.data.fineTuneExport",
    "settings.data.archivedChats",
    "settings.data.archiveAllChats",
    "settings.data.confirmBeforeDeleting",
    "settings.data.sandboxFiles",
    "settings.data.deletionSection",
    "settings.data.archives",
    "settings.data.archivedImages",
    "settings.data.archivedVideos",
    "settings.data.archivedAudio",
    "settings.data.uploadedFiles",
    "settings.library.dataStorage",
    "settings.chat.exportHistory",
    "settings.chat.exportConversations",
    "settings.chat.importChats",
    "settings.chat.clearAllChats",
  ],
  "api-keys": [
    "settings.apiKeys.title",
    "settings.apiKeys.description",
    "settings.apiKeys.accessTokens",
    "settings.apiKeys.audioApi.title",
    "settings.apiKeys.decisionApi.title",
    "settings.apiKeys.mcp.title",
    "settings.general.modelAutoSwitch.keepKv",
  ],
  // the English card labels cannot match localized keys, so the header carries both entries.
  "remote-lan": ["settings.remoteLan.title", "settings.remoteLan.description"],
  agents: [
    // every key needs a rendered data-settings-label as its scroll target.
    "settings.agents.title",
    "settings.agents.description",
    "settings.agents.intro",
    "settings.agents.agent",
    "settings.agents.model",
    "settings.agents.quantization",
    // subagent.title has no stable scroll target because its label mounts conditionally.
    "settings.agents.options.title",
    "settings.agents.remote.title",
    "settings.agents.passthrough.title",
    "settings.agents.dryRun.title",
    "settings.mcp.title",
    "settings.apiKeys.mcp.title",
  ],
  connections: [],
  voice: [
    "settings.voice.dictation.sectionTitle",
    "settings.voice.dictation.microphoneLabel",
    "settings.voice.dictation.languageLabel",
    "settings.voice.dictionary.sectionTitle",
    "settings.voice.recents.sectionTitle",
    "settings.voice.readAloud.sectionTitle",
    "settings.voice.readAloud.buttonLabel",
    "settings.voice.readAloud.autoLabel",
    "settings.voice.readAloud.engineLabel",
    "settings.voice.readAloud.voiceLabel",
    "settings.voice.readAloud.speedLabel",
    "settings.voice.readAloud.pitchLabel",
    "settings.voice.readAloud.volumeLabel",
    "settings.voice.readAloud.previewLabel",
  ],
  "keyboard-shortcuts": [
    "settings.keyboardShortcuts.title",
    "settings.keyboardShortcuts.actions.newChat.label",
    "settings.keyboardShortcuts.actions.newTemporaryChat.label",
    "settings.keyboardShortcuts.actions.archiveChat.label",
    "settings.keyboardShortcuts.actions.newStandaloneChat.label",
    "settings.keyboardShortcuts.actions.markChatUnread.label",
    "settings.keyboardShortcuts.actions.togglePinChat.label",
    "settings.keyboardShortcuts.actions.selectAllChats.label",
    "settings.keyboardShortcuts.actions.clearChatSelection.label",
    "settings.keyboardShortcuts.actions.deleteSelectedChats.label",
    "settings.keyboardShortcuts.actions.nextRecentlyViewedChat.label",
    "settings.keyboardShortcuts.actions.nextChat.label",
    "settings.keyboardShortcuts.actions.nextChatNeedingAttention.label",
    "settings.keyboardShortcuts.actions.previousRecentlyViewedChat.label",
    "settings.keyboardShortcuts.actions.previousChat.label",
    "settings.keyboardShortcuts.actions.goToRecentChat1.label",
    "settings.keyboardShortcuts.actions.goToRecentChat2.label",
    "settings.keyboardShortcuts.actions.goToRecentChat3.label",
    "settings.keyboardShortcuts.actions.goToRecentChat4.label",
    "settings.keyboardShortcuts.actions.goToRecentChat5.label",
    "settings.keyboardShortcuts.actions.goToRecentChat6.label",
    "settings.keyboardShortcuts.actions.switchToChat.label",
    "settings.keyboardShortcuts.actions.switchToProjects.label",
    "settings.keyboardShortcuts.actions.switchToHub.label",
    "settings.keyboardShortcuts.actions.switchToTrain.label",
    "settings.keyboardShortcuts.actions.switchToRecipes.label",
    "settings.keyboardShortcuts.actions.switchToImages.label",
    "settings.keyboardShortcuts.actions.switchToVideo.label",
    "settings.keyboardShortcuts.actions.switchToAudio.label",
    "settings.keyboardShortcuts.actions.switchToExport.label",
    "settings.keyboardShortcuts.actions.findInPage.label",
    "settings.keyboardShortcuts.actions.newBrowserTab.label",
    "settings.keyboardShortcuts.actions.toggleBrowserFullView.label",
    "settings.keyboardShortcuts.actions.toggleApiMonitor.label",
    "settings.keyboardShortcuts.actions.toggleSidebar.label",
    "settings.keyboardShortcuts.actions.openMcpServers.label",
    "settings.keyboardShortcuts.actions.clearAllUnreads.label",
    "settings.keyboardShortcuts.actions.logOut.label",
    "settings.keyboardShortcuts.actions.openSettings.label",
    "settings.keyboardShortcuts.actions.approveToolRequest.label",
    "settings.keyboardShortcuts.actions.declineToolRequest.label",
    "settings.keyboardShortcuts.actions.attachFiles.label",
    "settings.keyboardShortcuts.actions.openComposerMenu.label",
    "settings.keyboardShortcuts.actions.cycleReasoningEffort.label",
    "settings.keyboardShortcuts.actions.decreaseReasoningEffort.label",
    "settings.keyboardShortcuts.actions.increaseReasoningEffort.label",
    "settings.keyboardShortcuts.actions.openModelPicker.label",
    "settings.keyboardShortcuts.actions.openProjectPicker.label",
    "settings.keyboardShortcuts.actions.startDictation.label",
    "settings.keyboardShortcuts.actions.sendMessage.label",
    "settings.keyboardShortcuts.actions.queueMessage.label",
    "settings.keyboardShortcuts.actions.steerMessage.label",
    "settings.keyboardShortcuts.actions.stopGeneration.label",
    "settings.keyboardShortcuts.actions.copyChatAsMarkdown.label",
    "settings.keyboardShortcuts.actions.copySessionId.label",
    "settings.keyboardShortcuts.actions.forkChat.label",
    "settings.keyboardShortcuts.actions.openCommandPalette.label",
    "settings.keyboardShortcuts.actions.searchChats.label",
    "settings.keyboardShortcuts.actions.renameChat.label",
    "settings.keyboardShortcuts.actions.openKeyboardShortcuts.label",
  ],
  // The Windows rows render only on Windows, so they are not indexed.
  sandbox: [
    "settings.general.permissions.sectionTitle",
    "settings.sandbox.levelLabel",
    "settings.sandbox.levelRowLabel",
    "settings.sandbox.toolsSection",
    "settings.sandbox.python",
    "settings.sandbox.terminal",
  ],
  debugging: [
    "settings.debugging.logSection",
    "settings.debugging.source",
    "settings.debugging.path",
    "settings.debugging.mode",
    "settings.debugging.keywords",
  ],
  about: [
    "settings.about.updates",
    "settings.about.releaseNotes",
    "settings.about.documentation",
    "settings.about.help",
    "settings.about.feedback",
    "settings.about.hardware",
    "settings.about.license.sectionTitle",
    "settings.about.dangerZone",
    "settings.about.shutDownStudio",
  ],
};

export function createSettingsSearchIndex({
  desktop,
  closeToTray,
  menuBarIcon,
}: {
  desktop: boolean;
  closeToTray: boolean;
  menuBarIcon: boolean;
}): Record<SettingsTab, TranslationKey[]> {
  if (!desktop) {
    return SETTINGS_SEARCH_INDEX;
  }
  return {
    ...SETTINGS_SEARCH_INDEX,
    general: [
      ...SETTINGS_SEARCH_INDEX.general,
      "settings.about.updates",
      "settings.general.startup.sectionTitle",
      "settings.general.startup.launchAtLogin",
      ...(closeToTray ? (["settings.general.startup.closeToTray"] as const) : []),
      ...(menuBarIcon ? (["settings.general.startup.menuBarIcon"] as const) : []),
      // Desktop only, like the row itself: DesktopRepairControl renders nothing without a
      // Tauri repair controller, so indexing it on the web build would scroll to a row
      // that is not there. Worth indexing at all because the capability message for a host
      // whose PyTorch cannot use its GPUs says to "use Repair installation in Settings",
      // and searching Settings for "repair" answered "No settings found."
      "settings.general.repairInstall.label",
      "settings.general.fullInstall.label",
    ],
    // Desktop only, like the Rendering section it scrolls to.
    appearance: SETTINGS_SEARCH_INDEX.appearance.flatMap((key) =>
      key === "settings.appearance.sidebarNav.title"
        ? (["settings.appearance.gpuRendering.label", key] as const)
        : [key],
    ),
    browser: [...SETTINGS_SEARCH_INDEX.browser, "browser.downloadLocationSetting"],
    about: SETTINGS_SEARCH_INDEX.about.filter(
      (key) => key !== "settings.about.updates",
    ),
  };
}

const HUGGING_FACE_ONLY_ENTRIES: ReadonlySet<TranslationKey> = new Set([
  "settings.general.hub.endpoint",
  "settings.general.hub.datasetsServer",
]);

const FULL_INSTALL_ENTRY: TranslationKey = "settings.general.fullInstall.label";

// owner-only rows on tabs visible to every account.
const OWNER_ONLY_ENTRIES: ReadonlySet<TranslationKey> = new Set([
  "settings.general.mlWarmup.sectionTitle",
  "settings.general.mlWarmup.hardwareLabel",
  "settings.general.mlWarmup.textLabel",
  "settings.general.mlWarmup.datasetsLabel",
  "settings.general.mlWarmup.mediaLabel",
  "settings.general.mlWarmup.quantizationLabel",
  "settings.sandbox.toolsSection",
  "settings.sandbox.python",
  "settings.sandbox.terminal",
  "settings.apiKeys.mcp.title",
  "settings.general.modelAutoSwitch.keepKv",
  "settings.chat.toolResultLimit",
  "settings.chat.firstTokenLabel",
]);

export function renderedSearchEntries(
  index: Record<SettingsTab, TranslationKey[]>,
  tab: SettingsTab,
  hubSource: HubSource,
  isOwner = true,
  canUpgradeToFullInstall = false,
): TranslationKey[] {
  return index[tab].filter(
    (key) =>
      !(hubSource === "modelscope" && HUGGING_FACE_ONLY_ENTRIES.has(key)) &&
      (isOwner || !OWNER_ONLY_ENTRIES.has(key)) &&
      (canUpgradeToFullInstall || key !== FULL_INSTALL_ENTRY),
  );
}

/** Value is a translation key of space-separated synonyms; it is never rendered. */
export const SETTINGS_SEARCH_KEYWORDS: Partial<
  Record<TranslationKey, TranslationKey>
> = {
  "settings.resources.storage.modelsFolder":
    "settings.resources.storage.modelsFolderKeywords",
  "settings.sandbox.toolsSection": "settings.sandbox.setupKeywords",
  // A Chat only user searches for what is missing ("train", "pytorch", "video"), not "Install type".
  "settings.general.fullInstall.label": "settings.general.fullInstall.keywords",
  // "purge", "prune" and the tool names are in none of the labels, so the row
  // the feature is named after was unreachable by search.
  "settings.resources.storage.caches.label":
    "settings.resources.storage.caches.keywords",
  // match mlock, vram, ulimit, and pin even though the labels omit them.
  "settings.resources.modelMemory.title":
    "settings.resources.modelMemory.modelMemoryKeywords",
  "settings.resources.modelMemory.keepResident":
    "settings.resources.modelMemory.modelMemoryKeywords",
  "settings.resources.modelMemory.noRamReserve":
    "settings.resources.modelMemory.modelMemoryKeywords",
  // match swap, fit, evict and the model kinds the multi-model labels omit.
  "settings.resources.modelMemory.multiModel":
    "settings.resources.modelMemory.multiModelKeywords",
  "settings.general.modelAutoSwitch.mediaIdleUnload":
    "settings.resources.modelMemory.mediaIdleUnloadKeywords",
  "settings.general.modelAutoSwitch.keepKv":
    "settings.general.modelAutoSwitch.keepKvKeywords",
  "settings.chat.memory.title": "settings.chat.memory.keywords",
  "settings.chat.memory.enable": "settings.chat.memory.keywords",
  "settings.chat.autoCompact": "settings.chat.autoCompactKeywords",
  "settings.chat.keepRunningWhenTabClosed":
    "settings.chat.keepRunningWhenTabClosedKeywords",
  "settings.chat.firstTokenLabel": "settings.chat.firstTokenKeywords",
  "settings.chat.toolResultLimit": "settings.chat.toolResultLimitKeywords",
  // match action verbs omitted from these descriptive labels.
  "settings.chat.thinking.visibility": "settings.chat.visibilityKeywords",
  "settings.chat.tools.visibility": "settings.chat.visibilityKeywords",
  "settings.chat.tools.foldIntoThinking": "settings.chat.visibilityKeywords",
  "settings.chat.autoScroll": "settings.chat.autoScrollKeywords",
  "settings.chat.replyNotification": "settings.chat.replyNotificationKeywords",
  "settings.chat.showLinkPreviews": "settings.chat.showLinkPreviewsDescription",
  "settings.chat.showReplyTimes": "settings.chat.showReplyTimesKeywords",
  "settings.chat.showGenerationDetails": "settings.chat.showGenerationDetailsKeywords",
  "settings.chat.generationStatsUpdates": "settings.chat.generationStatsUpdatesKeywords",
  // match protocol and agent names omitted from the title.
  "settings.apiKeys.mcp.title": "settings.apiKeys.mcp.keywords",
  // the intro names only some agents; every listed one has to find this page.
  "settings.agents.agent": "settings.agents.agentKeywords",
};