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.

Studio: choose how often update notifications appear, including Unsloth updates (#13200)

Michael Han4111181edef8
diff --git a/studio/frontend/src/components/llama-update-banner.tsx b/studio/frontend/src/components/llama-update-banner.tsx
index 833e35fde66..44707bf4c1f 100644
--- a/studio/frontend/src/components/llama-update-banner.tsx
+++ b/studio/frontend/src/components/llama-update-banner.tsx
@@ -9,10 +9,12 @@ import {
useLlamaUpdateCheck,
} from "@/hooks/use-llama-update-check";
import {
- useShowAudioCppUpdateBanner,
- useShowLlamaUpdateBanner,
- useShowWhisperUpdateBanner,
-} from "@/hooks/use-llama-update-pref";
+ type NotificationChannel,
+ markNotificationShown,
+ useDocumentVisible,
+ useNotificationDue,
+ useNotificationFrequency,
+} from "@/hooks/use-notification-frequency";
import {
heldUpdateBannerPref,
llamaReleaseChanged,
@@ -114,9 +116,27 @@ export function LlamaUpdateBanner({
enabled = true,
positioned = true,
}: LlamaUpdateBannerProps): ReactElement | null {
- const showLlamaBannerPref = useShowLlamaUpdateBanner();
- const showWhisperBannerPref = useShowWhisperUpdateBanner();
- const showAudioCppBannerPref = useShowAudioCppUpdateBanner();
+ // The open card stays allowed after it records itself as shown.
+ const [shownChannel, setShownChannel] = useState<NotificationChannel | null>(
+ null,
+ );
+ const allowed = (channel: NotificationChannel, due: boolean, off: boolean) =>
+ !off && (due || shownChannel === channel);
+ const showLlamaBannerPref = allowed(
+ "llama",
+ useNotificationDue("llama"),
+ useNotificationFrequency("llama") === "off",
+ );
+ const showWhisperBannerPref = allowed(
+ "whisper",
+ useNotificationDue("whisper"),
+ useNotificationFrequency("whisper") === "off",
+ );
+ const showAudioCppBannerPref = allowed(
+ "audio",
+ useNotificationDue("audio"),
+ useNotificationFrequency("audio") === "off",
+ );
const [changelogVersion, setChangelogVersion] = useState<string | null>(null);
// Not gated on showBannerPref: this hook instance is the app-wide listener
// for a cross-tab reload_required resync (the settings-sheet's own instance
@@ -201,6 +221,22 @@ export function LlamaUpdateBanner({
visible &&
status != null &&
(llamaUpdateOffered(status) || applying);
+ const channel: NotificationChannel =
+ component === "whisper.cpp"
+ ? "whisper"
+ : component === "audio.cpp"
+ ? "audio"
+ : "llama";
+ const tabVisible = useDocumentVisible();
+ useEffect(() => {
+ // livePref: a chained apply can rename the held card to a muted component.
+ if (show && tabVisible && livePref && shownChannel !== channel) {
+ markNotificationShown(channel);
+ setShownChannel(channel);
+ } else if (!show && shownChannel !== null) {
+ setShownChannel(null);
+ }
+ }, [show, tabVisible, livePref, channel, shownChannel]);
// A migration re-applies the install's own automatic choice, so it can be offered at a
// release the machine already has, where the backend pair replaces the version line.
const backendChange =
diff --git a/studio/frontend/src/components/tauri/update-banner.tsx b/studio/frontend/src/components/tauri/update-banner.tsx
index 9a52bde90d3..50556c8a5b5 100644
--- a/studio/frontend/src/components/tauri/update-banner.tsx
+++ b/studio/frontend/src/components/tauri/update-banner.tsx
@@ -3,6 +3,7 @@
import { Button } from "@/components/ui/button";
import { ReleaseNotesPanel } from "@/components/update/release-notes-panel";
+import { useNotificationGate } from "@/hooks/use-notification-frequency";
import type {
DesktopUpdatePolicyMode,
RetainedUpdateFailure,
@@ -63,7 +64,12 @@ export function UpdateBanner({
const [notesVersion, setNotesVersion] = useState<string | null>(null);
const showFailure = Boolean(lastFailure) && !dismissed;
const showAvailable = status === "available" && !dismissed && !showFailure;
- const show = showFailure || (showAvailable && Boolean(info));
+ // Failures always show; only the offer follows the notification frequency.
+ const offerOpen = useNotificationGate(
+ "unsloth",
+ showAvailable && Boolean(info),
+ );
+ const show = showFailure || offerOpen;
const isManualLinuxPackage = updatePolicyMode === "manual_linux_package";
const installDisabled = isManualLinuxPackage
? manualReleaseUrl === null
diff --git a/studio/frontend/src/components/web/update-banner.tsx b/studio/frontend/src/components/web/update-banner.tsx
index b12d5ce8b7d..a4611822c6c 100644
--- a/studio/frontend/src/components/web/update-banner.tsx
+++ b/studio/frontend/src/components/web/update-banner.tsx
@@ -4,6 +4,7 @@
import { Button } from "@/components/ui/button";
import { ReleaseNotesPanel } from "@/components/update/release-notes-panel";
import { type DeviceType, usePlatformStore } from "@/config/env";
+import { useNotificationGate } from "@/hooks/use-notification-frequency";
import { useWebUpdateCheck } from "@/hooks/use-web-update-check";
import { isTauri } from "@/lib/api-base";
import { copyToClipboard } from "@/lib/copy-to-clipboard";
@@ -37,6 +38,7 @@ export function WebUpdateBanner({
positioned = true,
}: WebUpdateBannerProps): ReactElement | null {
const { status, dismiss, snooze } = useWebUpdateCheck({ enabled });
+ const open = useNotificationGate("unsloth", status != null && !isTauri);
const deviceType = usePlatformStore((s) => s.deviceType);
const installCmd = installCommandForDevice(deviceType);
const [copiedVersion, setCopiedVersion] = useState<string | null>(null);
@@ -74,7 +76,7 @@ export function WebUpdateBanner({
return (
<AnimatePresence>
- {status ? (
+ {status && open ? (
<motion.div
initial={{ opacity: 0, y: 12, scale: 0.96 }}
animate={{ opacity: 1, y: 0, scale: 1 }}
diff --git a/studio/frontend/src/features/settings/components/notification-frequency-select.tsx b/studio/frontend/src/features/settings/components/notification-frequency-select.tsx
new file mode 100644
index 00000000000..7e2b76bad04
--- /dev/null
+++ b/studio/frontend/src/features/settings/components/notification-frequency-select.tsx
@@ -0,0 +1,57 @@
+// 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 {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
+import {
+ NOTIFICATION_FREQUENCIES,
+ type NotificationChannel,
+ type NotificationFrequency,
+ setNotificationFrequency,
+ useNotificationFrequency,
+} from "@/hooks/use-notification-frequency";
+import { useT } from "@/i18n";
+
+const LABEL_KEYS = {
+ always: "settings.general.notifications.frequency.always",
+ daily: "settings.general.notifications.frequency.daily",
+ weekly: "settings.general.notifications.frequency.weekly",
+ biweekly: "settings.general.notifications.frequency.biweekly",
+ monthly: "settings.general.notifications.frequency.monthly",
+ off: "settings.general.notifications.frequency.off",
+} as const satisfies Record<NotificationFrequency, string>;
+
+export function NotificationFrequencySelect({
+ channel,
+ label,
+}: {
+ channel: NotificationChannel;
+ label: string;
+}) {
+ const t = useT();
+ const frequency = useNotificationFrequency(channel);
+ return (
+ <Select
+ value={frequency}
+ onValueChange={(value) =>
+ setNotificationFrequency(channel, value as NotificationFrequency)
+ }
+ >
+ <SelectTrigger aria-label={label} className="w-40" size="sm">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {NOTIFICATION_FREQUENCIES.map((value) => (
+ <SelectItem key={value} value={value}>
+ {t(LABEL_KEYS[value])}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ );
+}
diff --git a/studio/frontend/src/features/settings/settings-search.ts b/studio/frontend/src/features/settings/settings-search.ts
index 96944dbb30c..87b7bfe2dff 100644
--- a/studio/frontend/src/features/settings/settings-search.ts
+++ b/studio/frontend/src/features/settings/settings-search.ts
@@ -25,6 +25,7 @@ export const SETTINGS_SEARCH_INDEX: Record<SettingsTab, TranslationKey[]> = {
"settings.appearance.language.label",
"settings.appearance.language.spellCheck",
"settings.general.notifications.sectionTitle",
+ "settings.general.notifications.showUnslothUpdates",
"settings.general.notifications.showLlamaUpdates",
"settings.general.notifications.showWhisperUpdates",
"settings.general.notifications.showAudioCppUpdates",
diff --git a/studio/frontend/src/features/settings/tabs/general-tab.tsx b/studio/frontend/src/features/settings/tabs/general-tab.tsx
index 9425f40027f..38b0ae2cb3c 100644
--- a/studio/frontend/src/features/settings/tabs/general-tab.tsx
+++ b/studio/frontend/src/features/settings/tabs/general-tab.tsx
@@ -28,14 +28,7 @@ import {
emitTrainingRunsChanged,
TRAINING_UI_PREFERENCE_KEYS,
} from "@/features/training";
-import {
- setShowAudioCppUpdateBanner,
- setShowLlamaUpdateBanner,
- setShowWhisperUpdateBanner,
- useShowAudioCppUpdateBanner,
- useShowLlamaUpdateBanner,
- useShowWhisperUpdateBanner,
-} from "@/hooks/use-llama-update-pref";
+import { NOTIFICATION_PREF_KEYS } from "@/hooks/use-notification-frequency";
import { useHfTokenValidation } from "@/hooks";
import { LOCALE_STORAGE_KEY, useT } from "@/i18n";
import { isTauri } from "@/lib/api-base";
@@ -84,6 +77,7 @@ import { LanguageSelect } from "../components/language-select";
import { TRANSPORT_MODE_STORAGE_KEY } from "@/features/hub";
import { DownloadTransportRow } from "../components/download-transport-row";
import { HubSettingsSection } from "../components/hub-settings-section";
+import { NotificationFrequencySelect } from "../components/notification-frequency-select";
import { SettingsRow } from "../components/settings-row";
import { SettingsSection } from "../components/settings-section";
import { StudioVersionSection } from "../components/studio-version-section";
@@ -169,9 +163,7 @@ const PREFS_KEYS: string[] = [
// Guided tour flags
"tour:studio:v1",
// Update notifications
- "unsloth_show_llama_update_banner",
- "unsloth_show_whisper_update_banner",
- "unsloth_show_audio_cpp_update_banner",
+ ...NOTIFICATION_PREF_KEYS,
"unsloth_llama_update_offer_suppression",
"unsloth_monitor_overlay",
LOADED_MODELS_PREFERENCE_KEYS.show,
@@ -210,9 +202,6 @@ export function GeneralTab() {
(s) => s.persistenceError,
);
const hfTokenIsPersisting = useHfTokenStore((s) => s.isPersisting);
- const showLlamaUpdates = useShowLlamaUpdateBanner();
- const showWhisperUpdates = useShowWhisperUpdateBanner();
- const showAudioCppUpdates = useShowAudioCppUpdateBanner();
const showLoadedModels = useShowLoadedModels();
const spellCheck = useSpellCheck();
@@ -675,15 +664,26 @@ export function GeneralTab() {
onCheckedChange={setShowLoadedModels}
/>
</SettingsRow>
+ <SettingsRow
+ label={t("settings.general.notifications.showUnslothUpdates")}
+ description={t(
+ "settings.general.notifications.showUnslothUpdatesDescription",
+ )}
+ >
+ <NotificationFrequencySelect
+ channel="unsloth"
+ label={t("settings.general.notifications.showUnslothUpdates")}
+ />
+ </SettingsRow>
<SettingsRow
label={t("settings.general.notifications.showLlamaUpdates")}
description={t(
"settings.general.notifications.showLlamaUpdatesDescription",
)}
>
- <Switch
- checked={showLlamaUpdates}
- onCheckedChange={setShowLlamaUpdateBanner}
+ <NotificationFrequencySelect
+ channel="llama"
+ label={t("settings.general.notifications.showLlamaUpdates")}
/>
</SettingsRow>
<SettingsRow
@@ -692,9 +692,9 @@ export function GeneralTab() {
"settings.general.notifications.showWhisperUpdatesDescription",
)}
>
- <Switch
- checked={showWhisperUpdates}
- onCheckedChange={setShowWhisperUpdateBanner}
+ <NotificationFrequencySelect
+ channel="whisper"
+ label={t("settings.general.notifications.showWhisperUpdates")}
/>
</SettingsRow>
<SettingsRow
@@ -703,9 +703,9 @@ export function GeneralTab() {
"settings.general.notifications.showAudioCppUpdatesDescription",
)}
>
- <Switch
- checked={showAudioCppUpdates}
- onCheckedChange={setShowAudioCppUpdateBanner}
+ <NotificationFrequencySelect
+ channel="audio"
+ label={t("settings.general.notifications.showAudioCppUpdates")}
/>
</SettingsRow>
</SettingsSection>
diff --git a/studio/frontend/src/hooks/use-llama-update-pref.ts b/studio/frontend/src/hooks/use-llama-update-pref.ts
deleted file mode 100644
index 3749378f6a9..00000000000
--- a/studio/frontend/src/hooks/use-llama-update-pref.ts
+++ /dev/null
@@ -1,92 +0,0 @@
-// 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 { useSyncExternalStore } from "react";
-
-// Whether an update banner may appear, per component. On by default; only an
-// explicit "false" (Settings -> General -> Notifications) disables it. A switch
-// each: the components ship on their own schedules.
-const LLAMA_STORAGE_KEY = "unsloth_show_llama_update_banner";
-const WHISPER_STORAGE_KEY = "unsloth_show_whisper_update_banner";
-const AUDIO_CPP_STORAGE_KEY = "unsloth_show_audio_cpp_update_banner";
-
-const listeners = new Set<() => void>();
-
-function readPref(key: string): boolean {
- try {
- return localStorage.getItem(key) !== "false";
- } catch {
- return true;
- }
-}
-
-function writePref(key: string, show: boolean): void {
- try {
- if (show) {
- // Remove rather than store "true" so the default stays on.
- localStorage.removeItem(key);
- } else {
- localStorage.setItem(key, "false");
- }
- } catch {
- // storage unavailable
- }
- for (const listener of listeners) listener();
-}
-
-// One listener set for every key: a subscriber re-reads its own getter, so a
-// notification it did not need costs it a comparison.
-function subscribe(listener: () => void): () => void {
- listeners.add(listener);
- // Sync toggles made in another tab.
- const onStorage = (event: StorageEvent) => {
- if (
- event.key === LLAMA_STORAGE_KEY ||
- event.key === WHISPER_STORAGE_KEY ||
- event.key === AUDIO_CPP_STORAGE_KEY
- ) {
- listener();
- }
- };
- window.addEventListener("storage", onStorage);
- return () => {
- listeners.delete(listener);
- window.removeEventListener("storage", onStorage);
- };
-}
-
-export function getShowLlamaUpdateBanner(): boolean {
- return readPref(LLAMA_STORAGE_KEY);
-}
-
-export function setShowLlamaUpdateBanner(show: boolean): void {
- writePref(LLAMA_STORAGE_KEY, show);
-}
-
-export function useShowLlamaUpdateBanner(): boolean {
- return useSyncExternalStore(subscribe, getShowLlamaUpdateBanner);
-}
-
-export function getShowWhisperUpdateBanner(): boolean {
- return readPref(WHISPER_STORAGE_KEY);
-}
-
-export function setShowWhisperUpdateBanner(show: boolean): void {
- writePref(WHISPER_STORAGE_KEY, show);
-}
-
-export function useShowWhisperUpdateBanner(): boolean {
- return useSyncExternalStore(subscribe, getShowWhisperUpdateBanner);
-}
-
-export function getShowAudioCppUpdateBanner(): boolean {
- return readPref(AUDIO_CPP_STORAGE_KEY);
-}
-
-export function setShowAudioCppUpdateBanner(show: boolean): void {
- writePref(AUDIO_CPP_STORAGE_KEY, show);
-}
-
-export function useShowAudioCppUpdateBanner(): boolean {
- return useSyncExternalStore(subscribe, getShowAudioCppUpdateBanner);
-}
diff --git a/studio/frontend/src/hooks/use-notification-frequency.ts b/studio/frontend/src/hooks/use-notification-frequency.ts
new file mode 100644
index 00000000000..e6f8f9e971b
--- /dev/null
+++ b/studio/frontend/src/hooks/use-notification-frequency.ts
@@ -0,0 +1,216 @@
+// 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 { useEffect, useState, useSyncExternalStore } from "react";
+
+// How often each update notification may appear (Settings -> General -> Notifications).
+export const NOTIFICATION_FREQUENCIES = [
+ "always",
+ "daily",
+ "weekly",
+ "biweekly",
+ "monthly",
+ "off",
+] as const;
+export type NotificationFrequency = (typeof NOTIFICATION_FREQUENCIES)[number];
+
+export const NOTIFICATION_CHANNELS = [
+ "llama",
+ "whisper",
+ "audio",
+ "unsloth",
+] as const;
+export type NotificationChannel = (typeof NOTIFICATION_CHANNELS)[number];
+
+const DAY_MS = 24 * 60 * 60 * 1000;
+const PERIOD_MS: Partial<Record<NotificationFrequency, number>> = {
+ daily: DAY_MS,
+ weekly: 7 * DAY_MS,
+ biweekly: 14 * DAY_MS,
+ monthly: 30 * DAY_MS,
+};
+
+// whisper.cpp and audio.cpp only matter to speech and Audio users, so they ask less often.
+const DEFAULT_FREQUENCY: Partial<
+ Record<NotificationChannel, NotificationFrequency>
+> = {
+ whisper: "biweekly",
+ audio: "biweekly",
+};
+// setTimeout overflows past 2^31 - 1 ms.
+const MAX_TIMEOUT_MS = 2_147_483_647;
+
+// These were on/off switches; only "false" was ever stored, and it means off.
+const LEGACY_SWITCH_KEYS: Partial<Record<NotificationChannel, string>> = {
+ llama: "unsloth_show_llama_update_banner",
+ whisper: "unsloth_show_whisper_update_banner",
+ audio: "unsloth_show_audio_cpp_update_banner",
+};
+
+const frequencyKey = (channel: NotificationChannel) =>
+ `unsloth_${channel}_notification_frequency`;
+const lastShownKey = (channel: NotificationChannel) =>
+ `unsloth_${channel}_notification_last_shown`;
+
+/** Every key this module owns, for "Reset all local preferences". */
+export const NOTIFICATION_PREF_KEYS: readonly string[] = [
+ ...NOTIFICATION_CHANNELS.flatMap((c) => [frequencyKey(c), lastShownKey(c)]),
+ ...Object.values(LEGACY_SWITCH_KEYS),
+];
+
+const OWN_KEYS = new Set(NOTIFICATION_PREF_KEYS);
+const listeners = new Set<() => void>();
+
+function isFrequency(value: unknown): value is NotificationFrequency {
+ return (NOTIFICATION_FREQUENCIES as readonly unknown[]).includes(value);
+}
+
+export function getNotificationFrequency(
+ channel: NotificationChannel,
+): NotificationFrequency {
+ try {
+ const stored = localStorage.getItem(frequencyKey(channel));
+ if (isFrequency(stored)) return stored;
+ const legacy = LEGACY_SWITCH_KEYS[channel];
+ if (legacy && localStorage.getItem(legacy) === "false") return "off";
+ } catch {
+ // storage unavailable
+ }
+ return DEFAULT_FREQUENCY[channel] ?? "always";
+}
+
+export function setNotificationFrequency(
+ channel: NotificationChannel,
+ frequency: NotificationFrequency,
+): void {
+ try {
+ localStorage.setItem(frequencyKey(channel), frequency);
+ const legacy = LEGACY_SWITCH_KEYS[channel];
+ if (legacy) localStorage.removeItem(legacy);
+ } catch {
+ // storage unavailable
+ }
+ for (const listener of listeners) listener();
+}
+
+function getLastShown(channel: NotificationChannel): number | null {
+ try {
+ const value = Number(localStorage.getItem(lastShownKey(channel)));
+ return Number.isFinite(value) && value > 0 ? value : null;
+ } catch {
+ return null;
+ }
+}
+
+export function markNotificationShown(
+ channel: NotificationChannel,
+ now: number = Date.now(),
+): void {
+ try {
+ localStorage.setItem(lastShownKey(channel), String(now));
+ } catch {
+ // storage unavailable
+ }
+ for (const listener of listeners) listener();
+}
+
+/** Whether a notification last shown at `lastShown` may appear again at `now`. */
+export function notificationDue(
+ frequency: NotificationFrequency,
+ lastShown: number | null,
+ now: number,
+): boolean {
+ if (frequency === "off") return false;
+ const period = PERIOD_MS[frequency];
+ // A clock moved backwards reads as due rather than silencing it for good.
+ return (
+ period == null ||
+ lastShown == null ||
+ now - lastShown >= period ||
+ now < lastShown
+ );
+}
+
+function subscribe(listener: () => void): () => void {
+ listeners.add(listener);
+ // Sync changes made in another tab.
+ const onStorage = (event: StorageEvent) => {
+ if (event.key === null || OWN_KEYS.has(event.key)) listener();
+ };
+ window.addEventListener("storage", onStorage);
+ return () => {
+ listeners.delete(listener);
+ window.removeEventListener("storage", onStorage);
+ };
+}
+
+export function useNotificationFrequency(
+ channel: NotificationChannel,
+): NotificationFrequency {
+ return useSyncExternalStore(subscribe, () =>
+ getNotificationFrequency(channel),
+ );
+}
+
+/** Whether `channel` may show now; re-renders when its quiet period ends. */
+export function useNotificationDue(channel: NotificationChannel): boolean {
+ const frequency = useNotificationFrequency(channel);
+ const lastShown = useSyncExternalStore(subscribe, () =>
+ getLastShown(channel),
+ );
+ const [tick, setTick] = useState(0);
+ const due = notificationDue(frequency, lastShown, Date.now());
+ // `tick` re-arms the timer after a capped wake-up, which a monthly wait needs.
+ useEffect(() => {
+ const period = PERIOD_MS[frequency];
+ if (tick < 0 || due || period == null || lastShown == null) return;
+ const wait = Math.min(
+ Math.max(lastShown + period - Date.now(), 0) + 1000,
+ MAX_TIMEOUT_MS,
+ );
+ const timer = setTimeout(() => setTick((tick) => tick + 1), wait);
+ return () => clearTimeout(timer);
+ }, [due, frequency, lastShown, tick]);
+ return due;
+}
+
+function subscribeVisibility(listener: () => void): () => void {
+ document.addEventListener("visibilitychange", listener);
+ return () => document.removeEventListener("visibilitychange", listener);
+}
+
+/** Whether the user can see this tab; a hidden tab must not use up the quiet period. */
+export function useDocumentVisible(): boolean {
+ return useSyncExternalStore(
+ subscribeVisibility,
+ () =>
+ typeof document === "undefined" || document.visibilityState !== "hidden",
+ );
+}
+
+/**
+ * Whether a notification that `wanted` to show may show. Opening it in a visible tab
+ * records the time, and it stays open until `wanted` drops (dismiss, snooze, update) or
+ * the channel is off.
+ */
+export function useNotificationGate(
+ channel: NotificationChannel,
+ wanted: boolean,
+): boolean {
+ const due = useNotificationDue(channel);
+ const frequency = useNotificationFrequency(channel);
+ const visible = useDocumentVisible();
+ const [heldFor, setHeldFor] = useState<NotificationChannel | null>(null);
+ const held = heldFor === channel;
+ const open = wanted && frequency !== "off" && (held || due);
+ useEffect(() => {
+ if (open && !held && visible) {
+ markNotificationShown(channel);
+ setHeldFor(channel);
+ } else if ((!wanted || frequency === "off") && heldFor !== null) {
+ // Off releases the hold, so a later quiet period applies from the last showing.
+ setHeldFor(null);
+ }
+ }, [open, held, visible, wanted, heldFor, channel, frequency]);
+ return open;
+}
diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.ts
index b41b280ac8a..c601255b1fd 100644
--- a/studio/frontend/src/i18n/locales/ar.ts
+++ b/studio/frontend/src/i18n/locales/ar.ts
@@ -1659,6 +1659,17 @@ export const ar = {
showAudioCppUpdates: "إشعارات تحديث audio.cpp",
showAudioCppUpdatesDescription:
"التنبيه عندما تحتاج بيئة تشغيل audio.cpp إلى تحديث لتشغيل صفحات الصوت. أوقف التشغيل إذا كنت لا تستخدم الصوت أبدًا.",
+ showUnslothUpdates: "إشعارات تحديث Unsloth",
+ showUnslothUpdatesDescription:
+ "الإشعار عند توفر إصدار أحدث من Unsloth للتثبيت.",
+ frequency: {
+ always: "دائمًا",
+ daily: "مرة يوميًا",
+ weekly: "مرة أسبوعيًا",
+ biweekly: "كل أسبوعين",
+ monthly: "مرة شهريًا",
+ off: "إيقاف",
+ },
},
startup: {
sectionTitle: "بدء التشغيل",
diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.ts
index addc437bc60..b631f0a9226 100644
--- a/studio/frontend/src/i18n/locales/de.ts
+++ b/studio/frontend/src/i18n/locales/de.ts
@@ -1680,6 +1680,17 @@ export const de = {
showAudioCppUpdates: "audio.cpp-Update-Benachrichtigungen",
showAudioCppUpdatesDescription:
"Benachrichtigt, wenn die audio.cpp-Laufzeit ein Update für die Audio-Seiten braucht. Deaktivieren Sie dies, wenn Sie Audio nie verwenden.",
+ showUnslothUpdates: "Unsloth-Update-Benachrichtigungen",
+ showUnslothUpdatesDescription:
+ "Benachrichtigen, wenn eine neuere Unsloth-Version zur Installation bereitsteht.",
+ frequency: {
+ always: "Immer",
+ daily: "Einmal täglich",
+ weekly: "Einmal pro Woche",
+ biweekly: "Alle zwei Wochen",
+ monthly: "Einmal im Monat",
+ off: "Aus",
+ },
},
startup: {
sectionTitle: "Autostart",
diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.ts
index c4f5f29f201..71ec0b109c8 100644
--- a/studio/frontend/src/i18n/locales/en.ts
+++ b/studio/frontend/src/i18n/locales/en.ts
@@ -1718,6 +1718,17 @@ export const en = {
showAudioCppUpdates: "audio.cpp update notifications",
showAudioCppUpdatesDescription:
"Notify when the audio.cpp runtime needs an update to run the Audio pages. Turn off if you never use Audio.",
+ showUnslothUpdates: "Unsloth update notifications",
+ showUnslothUpdatesDescription:
+ "Notify when a newer version of Unsloth is available to install.",
+ frequency: {
+ always: "Always",
+ daily: "Once a day",
+ weekly: "Once a week",
+ biweekly: "Every two weeks",
+ monthly: "Once a month",
+ off: "Off",
+ },
},
startup: {
sectionTitle: "Startup",
diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.ts
index c7f74f550f8..30a1d16c79e 100644
--- a/studio/frontend/src/i18n/locales/es.ts
+++ b/studio/frontend/src/i18n/locales/es.ts
@@ -1676,6 +1676,17 @@ export const es = {
showAudioCppUpdates: "Notificaciones de actualización de audio.cpp",
showAudioCppUpdatesDescription:
"Avisa cuando el entorno de ejecución de audio.cpp necesite una actualización para las páginas de Audio. Desactívalo si nunca usas Audio.",
+ showUnslothUpdates: "Notificaciones de actualización de Unsloth",
+ showUnslothUpdatesDescription:
+ "Avisar cuando haya una versión más reciente de Unsloth para instalar.",
+ frequency: {
+ always: "Siempre",
+ daily: "Una vez al día",
+ weekly: "Una vez a la semana",
+ biweekly: "Cada dos semanas",
+ monthly: "Una vez al mes",
+ off: "Desactivado",
+ },
},
startup: {
sectionTitle: "Inicio",
diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.ts
index f448d4d6c1f..c6d790e3b01 100644
--- a/studio/frontend/src/i18n/locales/fr.ts
+++ b/studio/frontend/src/i18n/locales/fr.ts
@@ -1678,6 +1678,17 @@ export const fr = {
showAudioCppUpdates: "Notifications de mise à jour d'audio.cpp",
showAudioCppUpdatesDescription:
"Notifier lorsque le moteur audio.cpp doit être mis à jour pour les pages Audio. Désactivez si vous n'utilisez jamais Audio.",
+ showUnslothUpdates: "Notifications de mise à jour d'Unsloth",
+ showUnslothUpdatesDescription:
+ "Prévenir lorsqu'une version plus récente d'Unsloth est disponible à l'installation.",
+ frequency: {
+ always: "Toujours",
+ daily: "Une fois par jour",
+ weekly: "Une fois par semaine",
+ biweekly: "Toutes les deux semaines",
+ monthly: "Une fois par mois",
+ off: "Désactivé",
+ },
},
startup: {
sectionTitle: "Démarrage",
diff --git a/studio/frontend/src/i18n/locales/he.ts b/studio/frontend/src/i18n/locales/he.ts
index a464c6e13ed..3ca23d16683 100644
--- a/studio/frontend/src/i18n/locales/he.ts
+++ b/studio/frontend/src/i18n/locales/he.ts
@@ -1757,6 +1757,17 @@ export const he = {
showAudioCppUpdates: "התראות עדכון של audio.cpp",
showAudioCppUpdatesDescription:
"הודע כאשר סביבת הריצה של audio.cpp צריכה עדכון עבור דפי האודיו. כבה אם אינך משתמש באודיו אף פעם.",
+ showUnslothUpdates: "התראות עדכון של Unsloth",
+ showUnslothUpdatesDescription:
+ "הודעה כשגרסה חדשה יותר של Unsloth זמינה להתקנה.",
+ frequency: {
+ always: "תמיד",
+ daily: "פעם ביום",
+ weekly: "פעם בשבוע",
+ biweekly: "כל שבועיים",
+ monthly: "פעם בחודש",
+ off: "כבוי",
+ },
},
startup: {
sectionTitle: "הפעלה",
diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.ts
index bd05e87af84..23468efb8ae 100644
--- a/studio/frontend/src/i18n/locales/hi.ts
+++ b/studio/frontend/src/i18n/locales/hi.ts
@@ -1662,6 +1662,17 @@ export const hi = {
showAudioCppUpdates: "audio.cpp अपडेट सूचनाएं",
showAudioCppUpdatesDescription:
"जब ऑडियो पेजों के लिए audio.cpp रनटाइम को अपडेट की ज़रूरत हो तो सूचित करें। यदि आप कभी ऑडियो का उपयोग नहीं करते हैं तो बंद कर दें।",
+ showUnslothUpdates: "Unsloth अपडेट सूचनाएँ",
+ showUnslothUpdatesDescription:
+ "जब Unsloth का नया संस्करण इंस्टॉल करने के लिए उपलब्ध हो, तब सूचित करें।",
+ frequency: {
+ always: "हमेशा",
+ daily: "दिन में एक बार",
+ weekly: "सप्ताह में एक बार",
+ biweekly: "हर दो सप्ताह में",
+ monthly: "महीने में एक बार",
+ off: "बंद",
+ },
},
startup: {
sectionTitle: "स्टार्टअप",
diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.ts
index 53988346a4e..1ee0fed06ce 100644
--- a/studio/frontend/src/i18n/locales/it.ts
+++ b/studio/frontend/src/i18n/locales/it.ts
@@ -1657,6 +1657,17 @@ export const it = {
showAudioCppUpdates: "Notifiche di aggiornamento di audio.cpp",
showAudioCppUpdatesDescription:
"Avvisa quando il runtime di audio.cpp deve essere aggiornato per le pagine Audio. Disattiva le notifiche se non usi mai Audio.",
+ showUnslothUpdates: "Notifiche di aggiornamento di Unsloth",
+ showUnslothUpdatesDescription:
+ "Avvisa quando è disponibile una versione più recente di Unsloth da installare.",
+ frequency: {
+ always: "Sempre",
+ daily: "Una volta al giorno",
+ weekly: "Una volta a settimana",
+ biweekly: "Ogni due settimane",
+ monthly: "Una volta al mese",
+ off: "Disattivate",
+ },
},
startup: {
sectionTitle: "Avvio",
diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.ts
index 9a9f16d37d4..34c29294bf7 100644
--- a/studio/frontend/src/i18n/locales/ja.ts
+++ b/studio/frontend/src/i18n/locales/ja.ts
@@ -1647,6 +1647,17 @@ export const ja = {
showAudioCppUpdates: "audio.cpp のアップデート通知",
showAudioCppUpdatesDescription:
"音声ページに必要な audio.cpp ランタイムの更新があるときに通知します。音声機能を使わない場合はオフにしてください。",
+ showUnslothUpdates: "Unsloth のアップデート通知",
+ showUnslothUpdatesDescription:
+ "新しいバージョンの Unsloth をインストールできるようになったときに通知します。",
+ frequency: {
+ always: "常に",
+ daily: "1日1回",
+ weekly: "週に1回",
+ biweekly: "2週間に1回",
+ monthly: "月に1回",
+ off: "オフ",
+ },
},
startup: {
sectionTitle: "起動",
diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.ts
index 430a0b03420..e19ed3963a8 100644
--- a/studio/frontend/src/i18n/locales/ko.ts
+++ b/studio/frontend/src/i18n/locales/ko.ts
@@ -1656,6 +1656,17 @@ export const ko = {
showAudioCppUpdates: "audio.cpp 업데이트 알림",
showAudioCppUpdatesDescription:
"오디오 페이지에 필요한 audio.cpp 런타임 업데이트가 있으면 알립니다. 오디오를 사용하지 않는다면 끄세요.",
+ showUnslothUpdates: "Unsloth 업데이트 알림",
+ showUnslothUpdatesDescription:
+ "설치할 수 있는 새 Unsloth 버전이 있으면 알립니다.",
+ frequency: {
+ always: "항상",
+ daily: "하루에 한 번",
+ weekly: "일주일에 한 번",
+ biweekly: "2주에 한 번",
+ monthly: "한 달에 한 번",
+ off: "끄기",
+ },
},
startup: {
sectionTitle: "시작",
diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.ts
index 9806ba16731..2f584493512 100644
--- a/studio/frontend/src/i18n/locales/pt-br.ts
+++ b/studio/frontend/src/i18n/locales/pt-br.ts
@@ -1667,6 +1667,17 @@ export const ptBR = {
showAudioCppUpdates: "Notificações de atualização do audio.cpp",
showAudioCppUpdatesDescription:
"Notifica quando o runtime do audio.cpp precisa de uma atualização para as páginas de Áudio. Desative se você nunca usa Áudio.",
+ showUnslothUpdates: "Notificações de atualização do Unsloth",
+ showUnslothUpdatesDescription:
+ "Avisar quando houver uma versão mais recente do Unsloth para instalar.",
+ frequency: {
+ always: "Sempre",
+ daily: "Uma vez por dia",
+ weekly: "Uma vez por semana",
+ biweekly: "A cada duas semanas",
+ monthly: "Uma vez por mês",
+ off: "Desativado",
+ },
},
startup: {
sectionTitle: "Inicialização",
diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.ts
index 4b461f53e63..d6ac8e4add7 100644
--- a/studio/frontend/src/i18n/locales/ru.ts
+++ b/studio/frontend/src/i18n/locales/ru.ts
@@ -1663,6 +1663,17 @@ export const ru = {
showAudioCppUpdates: "Уведомления об обновлениях audio.cpp",
showAudioCppUpdatesDescription:
"Уведомлять, когда среде выполнения audio.cpp нужно обновление для страниц «Аудио». Отключите, если вы не пользуетесь аудио.",
+ showUnslothUpdates: "Уведомления об обновлениях Unsloth",
+ showUnslothUpdatesDescription:
+ "Сообщать, когда доступна новая версия Unsloth для установки.",
+ frequency: {
+ always: "Всегда",
+ daily: "Раз в день",
+ weekly: "Раз в неделю",
+ biweekly: "Раз в две недели",
+ monthly: "Раз в месяц",
+ off: "Выкл.",
+ },
},
startup: {
sectionTitle: "Автозапуск",
diff --git a/studio/frontend/src/i18n/locales/sv.ts b/studio/frontend/src/i18n/locales/sv.ts
index fc158e1e953..b0cf25a37c8 100644
--- a/studio/frontend/src/i18n/locales/sv.ts
+++ b/studio/frontend/src/i18n/locales/sv.ts
@@ -1819,6 +1819,17 @@ export const sv = {
showAudioCppUpdates: "Aviseringar om audio.cpp-uppdateringar",
showAudioCppUpdatesDescription:
"Avisera när audio.cpp-körmiljön behöver uppdateras för ljudsidorna. Stäng av om du aldrig använder ljud.",
+ showUnslothUpdates: "Uppdateringsaviseringar för Unsloth",
+ showUnslothUpdatesDescription:
+ "Meddela när en nyare version av Unsloth finns att installera.",
+ frequency: {
+ always: "Alltid",
+ daily: "En gång om dagen",
+ weekly: "En gång i veckan",
+ biweekly: "Varannan vecka",
+ monthly: "En gång i månaden",
+ off: "Av",
+ },
},
startup: {
sectionTitle: "Start",
diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.ts
index 83aef557eea..81e793b3531 100644
--- a/studio/frontend/src/i18n/locales/zh-CN.ts
+++ b/studio/frontend/src/i18n/locales/zh-CN.ts
@@ -1639,6 +1639,17 @@ export const zhCN = {
showAudioCppUpdates: "audio.cpp 更新通知",
showAudioCppUpdatesDescription:
"当音频页面所需的 audio.cpp 运行时需要更新时通知你。如果从不使用音频功能,可以关闭此项。",
+ showUnslothUpdates: "Unsloth 更新通知",
+ showUnslothUpdatesDescription:
+ "有新版本的 Unsloth 可供安装时通知。",
+ frequency: {
+ always: "总是",
+ daily: "每天一次",
+ weekly: "每周一次",
+ biweekly: "每两周一次",
+ monthly: "每月一次",
+ off: "关闭",
+ },
},
startup: {
sectionTitle: "启动",
diff --git a/studio/frontend/tests/general-settings-token-sync.test.ts b/studio/frontend/tests/general-settings-token-sync.test.ts
index 849897b13ad..4c72491376d 100644
--- a/studio/frontend/tests/general-settings-token-sync.test.ts
+++ b/studio/frontend/tests/general-settings-token-sync.test.ts
@@ -2,7 +2,6 @@
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
import assert from "node:assert/strict";
-import { readFileSync } from "node:fs";
import test from "node:test";
import {
@@ -16,17 +15,8 @@ const tabUrl = new URL(
import.meta.url,
);
-// Every update-banner preference the tab can import, read off the module itself: #12893 added
-// the audio.cpp banner to the tab after this test pinned three names, and every case failed on
-// the missing export. Setters are no-ops and readers say the banner is hidden.
-const updateBannerPrefStub = Object.fromEntries(
- [
- ...readFileSync(
- new URL("../src/hooks/use-llama-update-pref.ts", import.meta.url),
- "utf8",
- ).matchAll(/^export function (\w+)/gm),
- ].map(([, name]) => [name, name.startsWith("set") ? () => undefined : () => false]),
-);
+// The tab only reads the key list for its reset; the rows are a stubbed component.
+const notificationPrefStub = { NOTIFICATION_PREF_KEYS: [] };
type EffectSlot = {
cleanup?: () => void;
@@ -145,7 +135,7 @@ function generalTab(initialToken: string) {
emitTrainingRunsChanged: noop,
TRAINING_UI_PREFERENCE_KEYS: [],
},
- "@/hooks/use-llama-update-pref": updateBannerPrefStub,
+ "@/hooks/use-notification-frequency": notificationPrefStub,
"@/hooks": {
useHfTokenValidation: () => ({
isValid: false,
@@ -200,6 +190,7 @@ function generalTab(initialToken: string) {
"../components/language-select": componentStub,
"../components/download-transport-row": componentStub,
"../components/hub-settings-section": componentStub,
+ "../components/notification-frequency-select": componentStub,
"../components/settings-row": componentStub,
"../components/settings-section": componentStub,
"../components/studio-version-section": componentStub,
diff --git a/studio/frontend/tests/notification-frequency-hooks.test.ts b/studio/frontend/tests/notification-frequency-hooks.test.ts
new file mode 100644
index 00000000000..d1e6fb5e2a7
--- /dev/null
+++ b/studio/frontend/tests/notification-frequency-hooks.test.ts
@@ -0,0 +1,149 @@
+// 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 assert from "node:assert/strict";
+import test, { mock } from "node:test";
+
+import { installLocalStorageFake } from "./helpers/kit.ts";
+import { loadWithStubs } from "./helpers/module-stubs.ts";
+
+const { store } = installLocalStorageFake();
+const DAY = 24 * 60 * 60 * 1000;
+
+type Effect = {
+ deps?: unknown[];
+ cleanup?: () => void;
+ pending?: () => undefined | (() => void);
+};
+
+/** A one-component React: renders until no state or effect changes anything. */
+function fakeReact() {
+ const state: unknown[] = [];
+ const effects: Effect[] = [];
+ let index = 0;
+ let effectIndex = 0;
+ let dirty = false;
+ const react = {
+ useState<T>(initial: T) {
+ const i = index++;
+ if (!(i in state)) state[i] = initial;
+ const set = (next: T | ((prev: T) => T)) => {
+ const value =
+ typeof next === "function"
+ ? (next as (prev: T) => T)(state[i] as T)
+ : next;
+ if (!Object.is(value, state[i])) {
+ state[i] = value;
+ dirty = true;
+ }
+ };
+ return [state[i] as T, set] as const;
+ },
+ useEffect(effect: () => undefined | (() => void), deps: unknown[]) {
+ const slot = (effects[effectIndex++] ??= {});
+ if (!slot.deps || deps.some((d, k) => !Object.is(d, slot.deps?.[k]))) {
+ slot.deps = deps;
+ slot.pending = effect;
+ }
+ },
+ useSyncExternalStore: (_subscribe: unknown, get: () => unknown) => get(),
+ };
+ const render = <T>(hook: () => T): T => {
+ let result!: T;
+ for (let pass = 0; pass < 20; pass++) {
+ dirty = false;
+ index = 0;
+ effectIndex = 0;
+ result = hook();
+ for (const slot of effects) {
+ if (!slot.pending) continue;
+ slot.cleanup?.();
+ slot.cleanup = slot.pending() ?? undefined;
+ slot.pending = undefined;
+ }
+ if (!dirty) return result;
+ }
+ throw new Error("render did not settle");
+ };
+ return { react, render, isDirty: () => dirty };
+}
+
+function load() {
+ const fake = fakeReact();
+ const mod = loadWithStubs<
+ typeof import("../src/hooks/use-notification-frequency.ts")
+ >(new URL("../src/hooks/use-notification-frequency.ts", import.meta.url), {
+ react: fake.react,
+ });
+ return { ...fake, mod };
+}
+
+test("a monthly wait longer than setTimeout allows re-arms until it is due", () => {
+ store.clear();
+ const start = Date.UTC(2026, 0, 1);
+ mock.timers.enable({ apis: ["setTimeout", "Date"], now: start });
+ try {
+ const { mod, render, isDirty } = load();
+ mod.setNotificationFrequency("unsloth", "monthly");
+ mod.markNotificationShown("unsloth", start);
+ const due = () => mod.useNotificationDue("unsloth");
+ assert.equal(render(due), false);
+ // The first timer is capped near 24.9 days; it must hand over to a second one.
+ mock.timers.tick(25 * DAY);
+ assert.equal(isDirty(), true, "the capped wake-up re-renders");
+ assert.equal(render(due), false, "still inside the 30 days");
+ mock.timers.tick(5 * DAY + 2000);
+ assert.equal(isDirty(), true, "the second timer fires at day 30");
+ assert.equal(render(due), true);
+ } finally {
+ mock.timers.reset();
+ }
+});
+
+test("turning a channel off releases an open notification's hold", () => {
+ store.clear();
+ mock.timers.enable({
+ apis: ["setTimeout", "Date"],
+ now: Date.UTC(2026, 0, 1),
+ });
+ try {
+ const { mod, render } = load();
+ mod.setNotificationFrequency("unsloth", "daily");
+ const gate = () => mod.useNotificationGate("unsloth", true);
+ assert.equal(render(gate), true, "first showing");
+ mod.setNotificationFrequency("unsloth", "off");
+ assert.equal(render(gate), false);
+ // Back on a quiet period right after it was shown: it waits out the day.
+ mod.setNotificationFrequency("unsloth", "daily");
+ assert.equal(render(gate), false);
+ } finally {
+ mock.timers.reset();
+ }
+});
+
+test("a hidden tab does not use up the quiet period", () => {
+ store.clear();
+ const doc = {
+ visibilityState: "hidden",
+ addEventListener() {},
+ removeEventListener() {},
+ };
+ Object.assign(globalThis, { document: doc });
+ mock.timers.enable({
+ apis: ["setTimeout", "Date"],
+ now: Date.UTC(2026, 0, 1),
+ });
+ try {
+ const { mod, render } = load();
+ mod.setNotificationFrequency("unsloth", "weekly");
+ const gate = () => mod.useNotificationGate("unsloth", true);
+ render(gate);
+ assert.equal(store.has("unsloth_unsloth_notification_last_shown"), false);
+ doc.visibilityState = "visible";
+ assert.equal(render(gate), true);
+ assert.equal(store.has("unsloth_unsloth_notification_last_shown"), true);
+ } finally {
+ mock.timers.reset();
+ Reflect.deleteProperty(globalThis, "document");
+ }
+});
diff --git a/studio/frontend/tests/notification-frequency.test.ts b/studio/frontend/tests/notification-frequency.test.ts
new file mode 100644
index 00000000000..76cd7770af9
--- /dev/null
+++ b/studio/frontend/tests/notification-frequency.test.ts
@@ -0,0 +1,109 @@
+// 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 assert from "node:assert/strict";
+import test from "node:test";
+
+import { installLocalStorageFake } from "./helpers/kit.ts";
+
+const { store } = installLocalStorageFake();
+const {
+ NOTIFICATION_PREF_KEYS,
+ getNotificationFrequency,
+ markNotificationShown,
+ notificationDue,
+ setNotificationFrequency,
+} = await import("../src/hooks/use-notification-frequency.ts");
+
+const HOUR = 60 * 60 * 1000;
+const DAY = 24 * HOUR;
+
+test("each frequency decides when a notification may show again", () => {
+ const shown = 1_000_000_000_000;
+ assert.equal(notificationDue("always", shown, shown + 1), true);
+ assert.equal(notificationDue("off", null, shown), false);
+ for (const [frequency, period] of [
+ ["daily", DAY],
+ ["weekly", 7 * DAY],
+ ["biweekly", 14 * DAY],
+ ["monthly", 30 * DAY],
+ ] as const) {
+ assert.equal(
+ notificationDue(frequency, null, shown),
+ true,
+ `${frequency} never shown`,
+ );
+ assert.equal(
+ notificationDue(frequency, shown, shown + period - 1),
+ false,
+ frequency,
+ );
+ assert.equal(
+ notificationDue(frequency, shown, shown + period),
+ true,
+ frequency,
+ );
+ // A clock set back must not silence it until the clock catches up.
+ assert.equal(
+ notificationDue(frequency, shown, shown - HOUR),
+ true,
+ frequency,
+ );
+ }
+});
+
+test("the old on/off switches carry over", () => {
+ store.clear();
+ assert.equal(getNotificationFrequency("llama"), "always");
+ store.set("unsloth_show_llama_update_banner", "false");
+ assert.equal(getNotificationFrequency("llama"), "off");
+ // Playwright layout tests still write "true", which stays on.
+ store.set("unsloth_show_llama_update_banner", "true");
+ assert.equal(getNotificationFrequency("llama"), "always");
+ assert.equal(getNotificationFrequency("unsloth"), "always");
+});
+
+for (const [channel, legacy] of [
+ ["whisper", "unsloth_show_whisper_update_banner"],
+ ["audio", "unsloth_show_audio_cpp_update_banner"],
+] as const) {
+ test(`${channel} defaults to every two weeks, and a switched-off one stays off`, () => {
+ store.clear();
+ assert.equal(getNotificationFrequency(channel), "biweekly");
+ store.set(legacy, "false");
+ assert.equal(getNotificationFrequency(channel), "off");
+ setNotificationFrequency(channel, "always");
+ assert.equal(getNotificationFrequency(channel), "always");
+ });
+}
+
+test("choosing a frequency replaces the old switch", () => {
+ store.clear();
+ store.set("unsloth_show_audio_cpp_update_banner", "false");
+ setNotificationFrequency("audio", "weekly");
+ assert.equal(getNotificationFrequency("audio"), "weekly");
+ assert.equal(store.has("unsloth_show_audio_cpp_update_banner"), false);
+ store.set("unsloth_audio_notification_frequency", "hourly");
+ assert.equal(
+ getNotificationFrequency("audio"),
+ "biweekly",
+ "an unknown value falls back to the default",
+ );
+});
+
+test("showing records the time and reset clears every key", () => {
+ store.clear();
+ setNotificationFrequency("unsloth", "daily");
+ markNotificationShown("unsloth", 42);
+ assert.equal(store.get("unsloth_unsloth_notification_last_shown"), "42");
+ for (const key of store.keys()) {
+ assert.ok(NOTIFICATION_PREF_KEYS.includes(key), key);
+ }
+ for (const legacy of [
+ "unsloth_show_llama_update_banner",
+ "unsloth_show_whisper_update_banner",
+ "unsloth_show_audio_cpp_update_banner",
+ ]) {
+ assert.ok(NOTIFICATION_PREF_KEYS.includes(legacy), legacy);
+ }
+});