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: give whisper.cpp its own update notification switch (#11261)

Michael Han01b0d1fd34cd
diff --git a/studio/frontend/src/components/llama-update-banner.tsx b/studio/frontend/src/components/llama-update-banner.tsx
index 0baf588e82b..f1f12d03d55 100644
--- a/studio/frontend/src/components/llama-update-banner.tsx
+++ b/studio/frontend/src/components/llama-update-banner.tsx
@@ -8,10 +8,16 @@ import {
llamaUpdateOffered,
useLlamaUpdateCheck,
} from "@/hooks/use-llama-update-check";
-import { useShowLlamaUpdateBanner } from "@/hooks/use-llama-update-pref";
import {
+ useShowLlamaUpdateBanner,
+ useShowWhisperUpdateBanner,
+} from "@/hooks/use-llama-update-pref";
+import {
+ heldUpdateBannerPref,
llamaReleaseChanged,
llamaUpdateToastMessage,
+ updateBannerComponent,
+ updateToastTag,
} from "@/lib/llama-job-lifecycle";
import { toast } from "@/lib/toast";
import { cn } from "@/lib/utils";
@@ -107,7 +113,8 @@ export function LlamaUpdateBanner({
enabled = true,
positioned = true,
}: LlamaUpdateBannerProps): ReactElement | null {
- const showBannerPref = useShowLlamaUpdateBanner();
+ const showLlamaBannerPref = useShowLlamaUpdateBanner();
+ const showWhisperBannerPref = useShowWhisperUpdateBanner();
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
@@ -119,13 +126,32 @@ export function LlamaUpdateBanner({
onReloadRequired: resyncInferenceStatusAfterServerModelChange,
});
+ // The card names one component and the switches answer per component, so the
+ // shown one is picked here, before the version line and the toast read it.
+ const migrationPending = Boolean(status?.backend_migration_available);
+ const component = updateBannerComponent(
+ status?.component ?? "llama.cpp",
+ {
+ llama: Boolean(status?.llama.update_available) || migrationPending,
+ whisper: Boolean(status?.whisper?.update_available),
+ },
+ { llama: showLlamaBannerPref, whisper: showWhisperBannerPref },
+ );
+ // Its own release pair and download size, not the ones the backend put at the
+ // top level: those are llama's whatever the card shows.
+ const offer =
+ component === "whisper.cpp" ? status?.whisper : status?.llama;
+ const sizeBytes = offer?.update_size_bytes ?? null;
+ const latestTag = offer?.latest_tag ?? null;
+ const installedTag = offer?.installed_tag ?? null;
+
async function handleUpdate() {
- const component = status?.component ?? "llama.cpp";
// Read before applying: the status refreshes as the job runs.
- const migrating = Boolean(status?.backend_migration_available);
+ const migrating = migrationPending;
const result = await apply();
if (result?.ok) {
- const updatedTag = result.tag ?? status?.latest_tag ?? "the latest build";
+ const updatedTag =
+ updateToastTag(component, result.tag, latestTag) ?? "the latest build";
toast.success(
llamaUpdateToastMessage({
component,
@@ -142,15 +168,24 @@ export function LlamaUpdateBanner({
}
}
+ // Muted by the component the card shows.
+ const livePref =
+ component === "whisper.cpp" ? showWhisperBannerPref : showLlamaBannerPref;
+ // Held across a chained apply, which renames the card mid-job. An error counts
+ // as in flight so a failed phase keeps its retry on screen.
+ const jobState = status?.job.state;
+ const [heldPref, setHeldPref] = useState<boolean | null>(null);
+ useEffect(() => {
+ setHeldPref((prev) =>
+ heldUpdateBannerPref(prev, applying || jobState === "error", livePref),
+ );
+ }, [applying, jobState, livePref]);
+ const showBannerPref = heldPref ?? livePref;
const show =
showBannerPref &&
visible &&
status != null &&
(llamaUpdateOffered(status) || applying);
- const sizeBytes = status?.update_size_bytes ?? null;
- const component = status?.component ?? "llama.cpp";
- const latestTag = status?.latest_tag ?? null;
- const installedTag = status?.installed_tag ?? null;
// 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 =
@@ -158,7 +193,7 @@ export function LlamaUpdateBanner({
? `${backendLabel(status.from_backend)} \u2192 ${backendLabel(status.to_backend)}`
: null;
const versionChanged = llamaReleaseChanged(
- Boolean(status?.update_available),
+ Boolean(offer?.update_available),
installedTag,
latestTag,
);
diff --git a/studio/frontend/src/features/settings/settings-search.ts b/studio/frontend/src/features/settings/settings-search.ts
index 53b191cbc31..036b0bb84a4 100644
--- a/studio/frontend/src/features/settings/settings-search.ts
+++ b/studio/frontend/src/features/settings/settings-search.ts
@@ -19,6 +19,7 @@ export const SETTINGS_SEARCH_INDEX: Record<SettingsTab, TranslationKey[]> = {
"settings.appearance.language.label",
"settings.general.notifications.sectionTitle",
"settings.general.notifications.showLlamaUpdates",
+ "settings.general.notifications.showWhisperUpdates",
"settings.general.previewSharing.sectionTitle",
"settings.general.previewSharing.enableLabel",
"settings.general.previewSharing.revokeLabel",
diff --git a/studio/frontend/src/features/settings/tabs/general-tab.tsx b/studio/frontend/src/features/settings/tabs/general-tab.tsx
index 95e6849df7f..085fdec8df6 100644
--- a/studio/frontend/src/features/settings/tabs/general-tab.tsx
+++ b/studio/frontend/src/features/settings/tabs/general-tab.tsx
@@ -30,7 +30,9 @@ import {
} from "@/features/training";
import {
setShowLlamaUpdateBanner,
+ setShowWhisperUpdateBanner,
useShowLlamaUpdateBanner,
+ useShowWhisperUpdateBanner,
} from "@/hooks/use-llama-update-pref";
import { useHfTokenValidation } from "@/hooks";
import { LOCALE_STORAGE_KEY, useT } from "@/i18n";
@@ -150,6 +152,7 @@ const PREFS_KEYS: string[] = [
"tour:studio:v1",
// Update notifications
"unsloth_show_llama_update_banner",
+ "unsloth_show_whisper_update_banner",
"unsloth_monitor_overlay",
LOADED_MODELS_PREFERENCE_KEYS.show,
LOADED_MODELS_PREFERENCE_KEYS.collapsed,
@@ -187,6 +190,7 @@ export function GeneralTab() {
(s) => s.persistenceError,
);
const showLlamaUpdates = useShowLlamaUpdateBanner();
+ const showWhisperUpdates = useShowWhisperUpdateBanner();
const showLoadedModels = useShowLoadedModels();
const [draftToken, setDraftToken] = useState(hfToken ?? "");
@@ -611,6 +615,17 @@ export function GeneralTab() {
onCheckedChange={setShowLlamaUpdateBanner}
/>
</SettingsRow>
+ <SettingsRow
+ label={t("settings.general.notifications.showWhisperUpdates")}
+ description={t(
+ "settings.general.notifications.showWhisperUpdatesDescription",
+ )}
+ >
+ <Switch
+ checked={showWhisperUpdates}
+ onCheckedChange={setShowWhisperUpdateBanner}
+ />
+ </SettingsRow>
</SettingsSection>
{/* Installation-wide settings: owner-only routes, so a managed account gets no dead controls. */}
diff --git a/studio/frontend/src/hooks/use-llama-update-check.ts b/studio/frontend/src/hooks/use-llama-update-check.ts
index 8707656b52a..08c1d5ec8be 100644
--- a/studio/frontend/src/hooks/use-llama-update-check.ts
+++ b/studio/frontend/src/hooks/use-llama-update-check.ts
@@ -39,11 +39,22 @@ export interface LlamaUpdateJob {
finished_at: string | null;
}
+export interface ComponentOffer {
+ update_available: boolean;
+ installed_tag: string | null;
+ latest_tag: string | null;
+ update_size_bytes: number | null;
+}
+
export interface LlamaUpdateStatus {
supported: boolean;
update_available: boolean;
source_build: boolean;
component: "llama.cpp" | "whisper.cpp";
+ // Carried per component whatever the card names: both can be behind at once,
+ // and the card shows whichever one the notification switches allow.
+ llama: ComponentOffer;
+ whisper: ComponentOffer | null;
installed_tag: string | null;
latest_tag: string | null;
// Prebuilt download size in bytes, if known.
@@ -116,6 +127,34 @@ function parseStatus(value: unknown): LlamaUpdateStatus | null {
typeof details.update_size_bytes === "number"
? details.update_size_bytes
: null,
+ // The top-level version fields keep their llama meaning whatever `details` is.
+ llama: {
+ // Absent from a backend older than the whisper piggyback: there the legacy
+ // union is llama's own answer.
+ update_available:
+ typeof s.llama_update_available === "boolean"
+ ? s.llama_update_available
+ : s.update_available === true && component === "llama.cpp",
+ installed_tag: typeof s.installed_tag === "string" ? s.installed_tag : null,
+ latest_tag: typeof s.latest_tag === "string" ? s.latest_tag : null,
+ update_size_bytes:
+ typeof s.update_size_bytes === "number" ? s.update_size_bytes : null,
+ },
+ whisper: whisper
+ ? {
+ update_available: whisper.update_available === true,
+ installed_tag:
+ typeof whisper.installed_tag === "string"
+ ? whisper.installed_tag
+ : null,
+ latest_tag:
+ typeof whisper.latest_tag === "string" ? whisper.latest_tag : null,
+ update_size_bytes:
+ typeof whisper.update_size_bytes === "number"
+ ? whisper.update_size_bytes
+ : null,
+ }
+ : null,
// Always from the top level: the backend belongs to the llama.cpp install whatever
// component the version fields describe.
backend_migration_available: s.backend_migration_available === true,
diff --git a/studio/frontend/src/hooks/use-llama-update-pref.ts b/studio/frontend/src/hooks/use-llama-update-pref.ts
index 33a21965c45..0b3ec57af30 100644
--- a/studio/frontend/src/hooks/use-llama-update-pref.ts
+++ b/studio/frontend/src/hooks/use-llama-update-pref.ts
@@ -3,27 +3,29 @@
import { useSyncExternalStore } from "react";
-// Whether the llama.cpp update banner may appear. On by default; only an
-// explicit "false" (Settings -> General -> Notifications) disables it.
-const STORAGE_KEY = "unsloth_show_llama_update_banner";
+// Whether an update banner may appear, per component. On by default; only an
+// explicit "false" (Settings -> General -> Notifications) disables it. A switch
+// each: the two 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 listeners = new Set<() => void>();
-export function getShowLlamaUpdateBanner(): boolean {
+function readPref(key: string): boolean {
try {
- return localStorage.getItem(STORAGE_KEY) !== "false";
+ return localStorage.getItem(key) !== "false";
} catch {
return true;
}
}
-export function setShowLlamaUpdateBanner(show: boolean): void {
+function writePref(key: string, show: boolean): void {
try {
if (show) {
// Remove rather than store "true" so the default stays on.
- localStorage.removeItem(STORAGE_KEY);
+ localStorage.removeItem(key);
} else {
- localStorage.setItem(STORAGE_KEY, "false");
+ localStorage.setItem(key, "false");
}
} catch {
// storage unavailable
@@ -31,11 +33,15 @@ export function setShowLlamaUpdateBanner(show: boolean): void {
for (const listener of listeners) listener();
}
+// One listener set for both keys: 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 === STORAGE_KEY) listener();
+ if (event.key === LLAMA_STORAGE_KEY || event.key === WHISPER_STORAGE_KEY) {
+ listener();
+ }
};
window.addEventListener("storage", onStorage);
return () => {
@@ -44,6 +50,26 @@ function subscribe(listener: () => void): () => void {
};
}
+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);
+}
diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.ts
index 1eeae7ecfb8..9cf716297fc 100644
--- a/studio/frontend/src/i18n/locales/ar.ts
+++ b/studio/frontend/src/i18n/locales/ar.ts
@@ -875,6 +875,9 @@ export const ar = {
showLoadedModels: "مؤشر النماذج المحمّلة",
showLoadedModelsDescription:
"إظهار بطاقة صغيرة في الزاوية السفلية اليمنى تعرض كل نموذج موجود حاليًا في الذاكرة (الدردشة، الكلام، الصور، الفيديو)، مع زر لإخراج كل منها.",
+ showWhisperUpdates: "إشعارات تحديث whisper.cpp",
+ showWhisperUpdatesDescription:
+ "التنبيه عند توفر إصدار أحدث من whisper.cpp لنماذج تحويل الكلام إلى نص. أوقف التشغيل إذا كنت لا تفرّغ الصوت.",
},
startup: {
sectionTitle: "بدء التشغيل",
diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.ts
index 77557f3918e..2882e4ad464 100644
--- a/studio/frontend/src/i18n/locales/de.ts
+++ b/studio/frontend/src/i18n/locales/de.ts
@@ -894,6 +894,9 @@ export const de = {
showLoadedModels: "Anzeige geladener Modelle",
showLoadedModelsDescription:
"Zeigt unten rechts eine kleine Karte mit allen derzeit im Speicher befindlichen Modellen (Chat, Sprache, Bild, Video) und einer Schaltfläche, um jedes einzeln zu entladen.",
+ showWhisperUpdates: "whisper.cpp-Update-Benachrichtigungen",
+ showWhisperUpdatesDescription:
+ "Benachrichtigt, wenn ein neuerer whisper.cpp-Build für Speech-to-Text-Modelle verfügbar ist. Deaktivieren Sie dies, wenn Sie nie Audio transkribieren.",
},
startup: {
sectionTitle: "Autostart",
diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.ts
index 7a86e4b8ca2..17045b3e913 100644
--- a/studio/frontend/src/i18n/locales/en.ts
+++ b/studio/frontend/src/i18n/locales/en.ts
@@ -880,6 +880,9 @@ export const en = {
showLoadedModels: "Loaded models indicator",
showLoadedModelsDescription:
"Show a small card in the bottom-right corner listing every model currently in memory (chat, speech, image, video), with a button to eject each one.",
+ showWhisperUpdates: "whisper.cpp update notifications",
+ showWhisperUpdatesDescription:
+ "Notify when a newer whisper.cpp build is available for speech-to-text models. Turn off if you never transcribe audio.",
},
startup: {
sectionTitle: "Startup",
diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.ts
index 28800430c31..1c015ab9b6e 100644
--- a/studio/frontend/src/i18n/locales/es.ts
+++ b/studio/frontend/src/i18n/locales/es.ts
@@ -890,6 +890,9 @@ export const es = {
showLoadedModels: "Indicador de modelos cargados",
showLoadedModelsDescription:
"Muestra una pequeña tarjeta en la esquina inferior derecha con todos los modelos actualmente en memoria (chat, voz, imagen, vídeo), con un botón para expulsar cada uno.",
+ showWhisperUpdates: "Notificaciones de actualización de whisper.cpp",
+ showWhisperUpdatesDescription:
+ "Avisa cuando haya una compilación más reciente de whisper.cpp para los modelos de voz a texto. Desactívalo si nunca transcribes audio.",
},
startup: {
sectionTitle: "Inicio",
diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.ts
index 5b7919488f1..7c92297fcda 100644
--- a/studio/frontend/src/i18n/locales/fr.ts
+++ b/studio/frontend/src/i18n/locales/fr.ts
@@ -892,6 +892,9 @@ export const fr = {
showLoadedModels: "Indicateur des modèles chargés",
showLoadedModelsDescription:
"Affiche une petite carte en bas à droite listant tous les modèles actuellement en mémoire (chat, voix, image, vidéo), avec un bouton pour éjecter chacun d'eux.",
+ showWhisperUpdates: "Notifications de mise à jour de whisper.cpp",
+ showWhisperUpdatesDescription:
+ "Notifier lorsqu'une nouvelle version de whisper.cpp est disponible pour les modèles de transcription vocale. Désactivez si vous ne transcrivez jamais d'audio.",
},
startup: {
sectionTitle: "Démarrage",
diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.ts
index e42908702a6..edb9772ba59 100644
--- a/studio/frontend/src/i18n/locales/hi.ts
+++ b/studio/frontend/src/i18n/locales/hi.ts
@@ -878,6 +878,9 @@ export const hi = {
showLoadedModels: "लोड किए गए मॉडल का संकेतक",
showLoadedModelsDescription:
"नीचे दाएं कोने में एक छोटा कार्ड दिखाएं जिसमें वर्तमान में मेमोरी में मौजूद हर मॉडल (चैट, स्पीच, इमेज, वीडियो) सूचीबद्ध हो, और हर एक को हटाने के लिए एक बटन हो।",
+ showWhisperUpdates: "whisper.cpp अपडेट सूचनाएं",
+ showWhisperUpdatesDescription:
+ "स्पीच-टू-टेक्स्ट मॉडल के लिए जब कोई नया whisper.cpp बिल्ड उपलब्ध हो तो सूचित करें। यदि आप ऑडियो ट्रांसक्राइब नहीं करते हैं तो बंद कर दें।",
},
startup: {
sectionTitle: "स्टार्टअप",
diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.ts
index a15370cac03..8dbc4cfa09b 100644
--- a/studio/frontend/src/i18n/locales/it.ts
+++ b/studio/frontend/src/i18n/locales/it.ts
@@ -865,6 +865,9 @@ export const it = {
showLoadedModels: "Indicatore dei modelli caricati",
showLoadedModelsDescription:
"Mostra una piccola scheda in basso a destra con tutti i modelli attualmente in memoria (chat, voce, immagini, video), con un pulsante per rimuovere ciascuno.",
+ showWhisperUpdates: "Notifiche di aggiornamento di whisper.cpp",
+ showWhisperUpdatesDescription:
+ "Avvisa quando è disponibile una build più recente di whisper.cpp per i modelli di trascrizione vocale. Disattiva le notifiche se non trascrivi mai l'audio.",
},
startup: {
sectionTitle: "Avvio",
diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.ts
index bd95873f106..1045aba4b1c 100644
--- a/studio/frontend/src/i18n/locales/ja.ts
+++ b/studio/frontend/src/i18n/locales/ja.ts
@@ -865,6 +865,8 @@ export const ja = {
showLlamaUpdatesDescription: "新しいモデルを実行するための新しい llama.cpp ビルドが利用可能になったときに通知します。トレーニングのみを行う場合はオフにしてください。",
showLoadedModels: "読み込み済みモデルのインジケーター",
showLoadedModelsDescription: "現在メモリ上にあるすべてのモデル(チャット、音声、画像、動画)を一覧表示する小さなカードを右下に表示します。各モデルを解放するボタンが付いています。",
+ showWhisperUpdates: "whisper.cpp のアップデート通知",
+ showWhisperUpdatesDescription: "音声認識モデル向けの新しい whisper.cpp ビルドが利用可能になったときに通知します。音声を文字起こししない場合はオフにしてください。",
},
startup: {
sectionTitle: "起動",
diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.ts
index e1bb2e59c88..041ebd7a62c 100644
--- a/studio/frontend/src/i18n/locales/ko.ts
+++ b/studio/frontend/src/i18n/locales/ko.ts
@@ -872,6 +872,9 @@ export const ko = {
showLoadedModels: "로드된 모델 표시기",
showLoadedModelsDescription:
"현재 메모리에 있는 모든 모델(채팅, 음성, 이미지, 비디오)을 오른쪽 아래 작은 카드에 표시하고, 각각을 해제하는 버튼을 제공합니다.",
+ showWhisperUpdates: "whisper.cpp 업데이트 알림",
+ showWhisperUpdatesDescription:
+ "음성 인식 모델을 위한 최신 whisper.cpp 빌드가 있으면 알립니다. 오디오를 전사하지 않는다면 끄세요.",
},
startup: {
sectionTitle: "시작",
diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.ts
index 008f1fd19bb..f6d2f845294 100644
--- a/studio/frontend/src/i18n/locales/pt-br.ts
+++ b/studio/frontend/src/i18n/locales/pt-br.ts
@@ -881,6 +881,9 @@ export const ptBR = {
showLoadedModels: "Indicador de modelos carregados",
showLoadedModelsDescription:
"Mostra um pequeno cartão no canto inferior direito listando todos os modelos atualmente na memória (chat, fala, imagem, vídeo), com um botão para liberar cada um.",
+ showWhisperUpdates: "Notificações de atualização do whisper.cpp",
+ showWhisperUpdatesDescription:
+ "Notifica quando uma versão mais recente do whisper.cpp está disponível para modelos de fala para texto. Desative se você nunca transcreve áudio.",
},
startup: {
sectionTitle: "Inicialização",
diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.ts
index 413fb270ad2..492f23679f9 100644
--- a/studio/frontend/src/i18n/locales/ru.ts
+++ b/studio/frontend/src/i18n/locales/ru.ts
@@ -878,6 +878,9 @@ export const ru = {
showLoadedModels: "Индикатор загруженных моделей",
showLoadedModelsDescription:
"Показывает в правом нижнем углу небольшую карточку со всеми моделями, находящимися сейчас в памяти (чат, речь, изображения, видео), и кнопку для выгрузки каждой из них.",
+ showWhisperUpdates: "Уведомления об обновлениях whisper.cpp",
+ showWhisperUpdatesDescription:
+ "Уведомлять о доступности новой сборки whisper.cpp для моделей распознавания речи. Отключите, если вы не расшифровываете аудио.",
},
startup: {
sectionTitle: "Автозапуск",
diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.ts
index 4fc864666d0..a407edd45f3 100644
--- a/studio/frontend/src/i18n/locales/zh-CN.ts
+++ b/studio/frontend/src/i18n/locales/zh-CN.ts
@@ -856,6 +856,9 @@ export const zhCN = {
showLoadedModels: "已加载模型指示器",
showLoadedModelsDescription:
"在右下角显示一张小卡片,列出当前位于内存中的所有模型(聊天、语音、图像、视频),并为每个模型提供卸载按钮。",
+ showWhisperUpdates: "whisper.cpp 更新通知",
+ showWhisperUpdatesDescription:
+ "当有可用于语音识别模型的新版 whisper.cpp 构建时通知你。如果不需要转写音频,可以关闭此项。",
},
startup: {
sectionTitle: "启动",
diff --git a/studio/frontend/src/lib/llama-job-lifecycle.ts b/studio/frontend/src/lib/llama-job-lifecycle.ts
index 365ea45a129..75d788edf76 100644
--- a/studio/frontend/src/lib/llama-job-lifecycle.ts
+++ b/studio/frontend/src/lib/llama-job-lifecycle.ts
@@ -68,6 +68,69 @@ export function llamaUpdatePresentation(
};
}
+export type UpdateComponent = "llama.cpp" | "whisper.cpp";
+
+export interface UpdateComponentFlags {
+ llama: boolean;
+ whisper: boolean;
+}
+
+/**
+ * Which component's offer the single update card shows.
+ *
+ * Both can be pending at once and the backend names only one: llama.cpp when its
+ * release is behind, whisper.cpp otherwise, so a llama.cpp backend migration is
+ * named whisper.cpp when whisper is stale too. If the named one's switch is off
+ * and the other has an offer the user does allow, the card shows that one rather
+ * than nothing. Update installs everything pending either way.
+ */
+export function updateBannerComponent(
+ named: UpdateComponent,
+ pending: UpdateComponentFlags,
+ allow: UpdateComponentFlags,
+): UpdateComponent {
+ const key = named === "whisper.cpp" ? "whisper" : "llama";
+ if (allow[key]) {
+ return named;
+ }
+ const other = key === "whisper" ? "llama" : "whisper";
+ return allow[other] && pending[other]
+ ? ((other === "whisper" ? "whisper.cpp" : "llama.cpp") as UpdateComponent)
+ : named;
+}
+
+/**
+ * The tag a finished update reports.
+ *
+ * The job's `to_tag` is the llama.cpp build by definition, so a card showing the
+ * whisper.cpp offer reports the release it advertised instead of llama's.
+ */
+export function updateToastTag(
+ component: UpdateComponent,
+ jobTag: string | null | undefined,
+ offerTag: string | null | undefined,
+): string | null {
+ const preferred = component === "whisper.cpp" ? offerTag : jobTag;
+ return preferred ?? offerTag ?? jobTag ?? null;
+}
+
+/**
+ * Which notification switch answers for the update card, held across a job.
+ *
+ * The card is muted by the component it names, and a chained apply renames it
+ * when the llama.cpp phase lands and the whisper.cpp phase starts. Reading the
+ * live switch there would take a running update off screen halfway through, so
+ * the switch the card started under is held until the job is over. `null` means
+ * nothing is held and the live switch applies.
+ */
+export function heldUpdateBannerPref(
+ held: boolean | null,
+ inFlight: boolean,
+ live: boolean,
+): boolean | null {
+ return inFlight ? (held ?? live) : null;
+}
+
/**
* Whether the banner's version line has anything to say.
*
diff --git a/studio/frontend/tests/llama-job-lifecycle.test.ts b/studio/frontend/tests/llama-job-lifecycle.test.ts
index 96d5f619413..cdd1d10d267 100644
--- a/studio/frontend/tests/llama-job-lifecycle.test.ts
+++ b/studio/frontend/tests/llama-job-lifecycle.test.ts
@@ -4,6 +4,9 @@
import assert from "node:assert/strict";
import test from "node:test";
import {
+ heldUpdateBannerPref,
+ updateBannerComponent,
+ updateToastTag,
llamaReleaseChanged,
llamaUpdateAdoptsRunningJob,
llamaUpdatePresentation,
@@ -195,3 +198,75 @@ test("an ordinary update still reports the release it moved to", () => {
"llama.cpp updated to b9600-mix-def.",
);
});
+
+// The card is muted per component, and a chained apply renames it when the
+// llama.cpp phase lands and the whisper.cpp phase starts. Reading the live
+// switch there hid a running update for the whole second phase.
+test("the switch a running card started under is held until the job is over", () => {
+ // llama.cpp notifications on, whisper.cpp off, chained update accepted.
+ let held = heldUpdateBannerPref(null, true, true);
+ assert.equal(held, true);
+ // The llama phase lands and the status renames the card mid-job.
+ held = heldUpdateBannerPref(held, true, false);
+ assert.equal(held, true, "the running update was taken off screen");
+ // The whisper phase fails: its retry has to stay reachable.
+ held = heldUpdateBannerPref(held, true, false);
+ assert.equal(held, true);
+ // Job over: the live switch answers again.
+ assert.equal(heldUpdateBannerPref(held, false, false), null);
+});
+
+test("a muted card stays muted for a job it never showed", () => {
+ // Nothing held, whisper.cpp muted, a whisper job running from another surface.
+ assert.equal(heldUpdateBannerPref(null, true, false), false);
+ // And an offer with no job in flight always reads the live switch.
+ assert.equal(heldUpdateBannerPref(null, false, true), null);
+});
+
+// Both components can be pending at once and the backend names only one, so the
+// switch of the one it did not name had nothing to answer for.
+test("the card shows the offer the switches allow", () => {
+ const on = { llama: true, whisper: true };
+ const bothStale = { llama: true, whisper: true };
+ assert.equal(updateBannerComponent("llama.cpp", bothStale, on), "llama.cpp");
+ assert.equal(updateBannerComponent("whisper.cpp", bothStale, on), "whisper.cpp");
+ // llama.cpp muted, whisper.cpp on, both pending: show the one asked for.
+ assert.equal(
+ updateBannerComponent("llama.cpp", bothStale, { llama: false, whisper: true }),
+ "whisper.cpp",
+ );
+ // And the reverse: a llama.cpp backend migration is named whisper.cpp when
+ // whisper is stale as well, so it needs the same swap back.
+ assert.equal(
+ updateBannerComponent("whisper.cpp", bothStale, { llama: true, whisper: false }),
+ "llama.cpp",
+ );
+ // Nothing to swap to when the other component has no offer.
+ assert.equal(
+ updateBannerComponent(
+ "llama.cpp",
+ { llama: true, whisper: false },
+ { llama: false, whisper: true },
+ ),
+ "llama.cpp",
+ );
+ // Both muted: the name the backend gave stands, and the card stays hidden.
+ assert.equal(
+ updateBannerComponent("llama.cpp", bothStale, { llama: false, whisper: false }),
+ "llama.cpp",
+ );
+});
+
+// The job reports the llama.cpp build it installed, which is not what a card
+// showing the whisper.cpp offer told the user it was getting.
+test("a finished update reports the release its card advertised", () => {
+ assert.equal(
+ updateToastTag("whisper.cpp", "b11100", "v1.9.4-unsloth.4"),
+ "v1.9.4-unsloth.4",
+ );
+ assert.equal(updateToastTag("llama.cpp", "b11100", "b11100"), "b11100");
+ // Either side falls back to the other rather than reporting nothing.
+ assert.equal(updateToastTag("whisper.cpp", "b11100", null), "b11100");
+ assert.equal(updateToastTag("llama.cpp", null, "b11100"), "b11100");
+ assert.equal(updateToastTag("llama.cpp", null, null), null);
+});