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.

2.7 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 SettingsTab,
  useSettingsDialogStore,
} from "@/features/settings/stores/settings-dialog-store";
import { settingsTabVisible } from "@/features/settings/settings-tab-visibility";
import type { TranslationKey } from "@/i18n";
import { ChipIcon } from "@/lib/hugeicons-derived";
import { openLink } from "@/lib/open-link";
import {
  Book03Icon,
  ComputerTerminal01Icon,
  EnergyRectangleIcon,
  MessageNotification01Icon,
  NewReleasesIcon,
} from "@hugeicons/core-free-icons";
import type { IconSvgElement } from "@hugeicons/react";

/** Must match the desktop Help menu (src-tauri/src/app_menu.rs, HELP_ROWS). */
export type HelpAction =
  | "help-documentation"
  | "help-keyboard-shortcuts"
  | "help-whats-new"
  | "help-troubleshooting"
  | "help-system-status"
  | "help-send-feedback";

export const HELP_GROUPS: HelpAction[][] = [
  ["help-documentation", "help-keyboard-shortcuts", "help-whats-new"],
  ["help-troubleshooting", "help-system-status", "help-send-feedback"],
];

export const HELP_ITEMS: Record<HelpAction, { label: TranslationKey; icon: IconSvgElement }> = {
  "help-documentation": { label: "shell.helpMenu.documentation", icon: Book03Icon },
  "help-keyboard-shortcuts": { label: "shell.helpMenu.keyboardShortcuts", icon: EnergyRectangleIcon },
  "help-whats-new": { label: "shell.helpMenu.whatsNew", icon: NewReleasesIcon },
  "help-troubleshooting": { label: "shell.helpMenu.troubleshooting", icon: ComputerTerminal01Icon },
  "help-system-status": { label: "shell.helpMenu.systemStatus", icon: ChipIcon },
  "help-send-feedback": { label: "shell.helpMenu.sendFeedback", icon: MessageNotification01Icon },
};

const HELP_SETTINGS_TABS: Partial<Record<HelpAction, SettingsTab>> = {
  "help-keyboard-shortcuts": "keyboard-shortcuts",
  "help-troubleshooting": "debugging",
  "help-system-status": "resources",
};

/** False when the action's Settings page is owner-only and this account cannot open it. */
export function helpActionAvailable(action: HelpAction, isOwner: boolean): boolean {
  const tab = HELP_SETTINGS_TABS[action];
  return !tab || settingsTabVisible(tab, isOwner);
}

export function runHelpAction(action: HelpAction): void {
  const tab = HELP_SETTINGS_TABS[action];
  if (tab) {
    useSettingsDialogStore.getState().openDialog(tab);
    return;
  }
  switch (action) {
    case "help-documentation":
      openLink("https://unsloth.ai/docs");
      return;
    case "help-whats-new":
      openLink("https://unsloth.ai/docs/new/changelog");
      return;
    case "help-send-feedback":
      openLink("https://github.com/unslothai/unsloth/issues");
      return;
  }
}