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: show pending llama.cpp, whisper.cpp and audio.cpp updates on one card (#13497)

oobaboogaf2321e9a1403
diff --git a/studio/frontend/src/components/llama-update-banner.tsx b/studio/frontend/src/components/llama-update-banner.tsx
index 44707bf4c1f..52c123731b2 100644
--- a/studio/frontend/src/components/llama-update-banner.tsx
+++ b/studio/frontend/src/components/llama-update-banner.tsx
@@ -16,21 +16,33 @@ import {
useNotificationFrequency,
} from "@/hooks/use-notification-frequency";
import {
+ type UpdateComponent,
+ type UpdateComponentFlags,
+ audibleComponents,
+ heldJobRows,
heldUpdateBannerPref,
llamaReleaseChanged,
llamaUpdateToastMessage,
- updateBannerComponent,
+ updateBannerAllowed,
+ updateBannerComponents,
+ updateComponentKey,
+ updateComponentsLabel,
updateToastTag,
} from "@/lib/llama-job-lifecycle";
import { toast } from "@/lib/toast";
import { cn } from "@/lib/utils";
import { Download } from "lucide-react";
-import { type ReactElement, useEffect, useRef, useState } from "react";
-// Creep toward this cap between coarse backend progress updates.
+import {
+ type CSSProperties,
+ type ReactElement,
+ useEffect,
+ useRef,
+ useState,
+} from "react";
+// cap for interpolation between coarse backend progress updates.
const RUNNING_CAP = 0.95;
-// The banner is not translated, so these mirror features/settings/lib/llama-backend-
-// labels.ts. An unknown backend prints its own identifier rather than nothing.
+// untranslated labels mirror llama-backend-labels.ts; unknown backends keep their identifiers.
const BACKEND_LABELS: Record<string, string> = {
auto: "Automatic",
cpu: "CPU",
@@ -111,181 +123,254 @@ interface LlamaUpdateBannerProps {
positioned?: boolean;
}
-/** Bottom-right llama.cpp update toast. */
+function sizeLabelOf(sizeBytes: number | null | undefined): string | null {
+ return sizeBytes && sizeBytes > 0
+ ? `${Math.round(sizeBytes / (1024 * 1024))} MB`
+ : null;
+}
+
+interface UpdateRow {
+ component: UpdateComponent;
+ installedTag: string | null;
+ latestTag: string | null;
+ sizeBytes: number | null;
+ versionChanged: boolean;
+}
+
+function VersionLine({
+ row,
+ bundled,
+ backendPair,
+}: {
+ row: UpdateRow;
+ bundled: boolean;
+ backendPair: readonly [string, string] | null;
+}): ReactElement {
+ const [from, to] = backendPair ?? [
+ row.installedTag ?? "unknown",
+ row.latestTag ?? "",
+ ];
+ const rowSize = bundled ? sizeLabelOf(row.sizeBytes) : null;
+ const sizeSuffix = rowSize ? ` · ${rowSize}` : "";
+ return (
+ <p
+ // one row per line keeps the changelog height calculation exact.
+ className={cn(
+ "mt-0.5 text-xs text-muted-foreground",
+ bundled && "truncate",
+ )}
+ title={
+ bundled
+ ? `${row.component} ${from} \u2192 ${to}${sizeSuffix}`
+ : undefined
+ }
+ data-testid="llama-update-version-line"
+ >
+ {bundled ? (
+ <span className="text-foreground">{row.component} </span>
+ ) : null}
+ {from} &rarr; <span className="font-medium text-foreground">{to}</span>
+ {sizeSuffix}
+ </p>
+ );
+}
+
export function LlamaUpdateBanner({
enabled = true,
positioned = true,
}: LlamaUpdateBannerProps): ReactElement | null {
- // 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",
- );
+ // an open card remains allowed after recording its components as shown.
+ const [shownChannels, setShownChannels] = useState<
+ readonly NotificationChannel[]
+ >([]);
+ const due: UpdateComponentFlags = {
+ llama: useNotificationDue("llama"),
+ whisper: useNotificationDue("whisper"),
+ audio: useNotificationDue("audio"),
+ };
+ const muted: UpdateComponentFlags = {
+ llama: useNotificationFrequency("llama") === "off",
+ whisper: useNotificationFrequency("whisper") === "off",
+ 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
- // only runs during an MTP-fallback rebuild), so muting the banner must not
- // also silence that resync -- it only suppresses the UI below.
+ // listen regardless of banner preference so muting the UI does not silence cross-tab reload_required resync.
const { status, visible, applying, apply, dismiss, snooze } =
useLlamaUpdateCheck({
enabled,
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),
- audio: Boolean(status?.audio?.update_available),
- },
- {
- llama: showLlamaBannerPref,
- whisper: showWhisperBannerPref,
- audio: showAudioCppBannerPref,
- },
- );
- // 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
- : component === "audio.cpp"
- ? status?.audio
- : status?.llama;
- const sizeBytes = offer?.update_size_bytes ?? null;
- const latestTag = offer?.latest_tag ?? null;
- const installedTag = offer?.installed_tag ?? null;
+ const listed = updateBannerComponents({
+ llama: Boolean(status?.llama.update_available) || migrationPending,
+ whisper: Boolean(status?.whisper?.update_available),
+ audio: Boolean(status?.audio?.update_available),
+ });
+ // muted components stay listed because update installs them, but they are not recorded.
+ const recordKey = audibleComponents(listed, muted)
+ .map(updateComponentKey)
+ .join(" ");
+ // use each component's release pair and size because the top-level fields belong to llama.cpp.
+ const liveRows: UpdateRow[] = listed.map((component) => {
+ const offer = status?.[updateComponentKey(component)];
+ const installedTag = offer?.installed_tag ?? null;
+ const latestTag = offer?.latest_tag ?? null;
+ return {
+ component,
+ installedTag,
+ latestTag,
+ sizeBytes: offer?.update_size_bytes ?? null,
+ versionChanged: llamaReleaseChanged(
+ Boolean(offer?.update_available),
+ installedTag,
+ latestTag,
+ ),
+ };
+ });
+ // treat errors as in flight so a failed phase keeps its retry visible.
+ const jobState = status?.job.state;
+ const inFlight = applying || jobState === "error";
+ const [jobRows, setJobRows] = useState<UpdateRow[] | null>(null);
+ const nextJobRows = heldJobRows(jobRows, applying, liveRows);
+ if (nextJobRows !== jobRows) {
+ setJobRows(nextJobRows);
+ }
+ const rows = jobRows ?? liveRows;
+ const label = updateComponentsLabel(rows.map((row) => row.component));
+ const bundled = rows.length > 1;
+ const llamaRow = rows.find((row) => row.component === "llama.cpp") ?? null;
+ const primary = rows[0] ?? null;
async function handleUpdate() {
- // Read before applying (the status refreshes mid-job). An audio.cpp update may keep
- // the old runtime, so only the job's message says what happened, as for a migration.
- const migrating = migrationPending || component === "audio.cpp";
+ // prefer the job message for bundles, migrations, and unchanged audio runtimes after refresh.
+ const fromJob =
+ migrationPending || bundled || primary?.component === "audio.cpp";
+ const offerTag = primary?.latestTag ?? null;
const result = await apply();
if (result?.ok) {
- const updatedTag =
- updateToastTag(component, result.tag, latestTag) ?? "the latest build";
+ const updatedTag = bundled
+ ? null
+ : (updateToastTag(
+ primary?.component ?? "llama.cpp",
+ result.tag,
+ offerTag,
+ ) ?? "the latest build");
toast.success(
llamaUpdateToastMessage({
- component,
- migrating,
+ component: label,
+ migrating: fromJob,
jobMessage: result.message,
updatedTag,
reloadRequired: result.reloadRequired,
}),
);
} else if (result) {
- // The failing phase need not be the component the card names.
+ // the failing phase may differ from the component named by the card.
toast.error(`Update failed: ${result.error ?? "unknown error"}`);
}
}
- // Muted by the component the card shows.
- const livePref =
- component === "whisper.cpp"
- ? showWhisperBannerPref
- : component === "audio.cpp"
- ? showAudioCppBannerPref
- : 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 livePref = updateBannerAllowed(
+ listed,
+ due,
+ muted,
+ shownChannels.length > 0,
+ );
+ // keep the preference while a chained apply removes completed components from status.
const [heldPref, setHeldPref] = useState<boolean | null>(null);
useEffect(() => {
- setHeldPref((prev) =>
- heldUpdateBannerPref(prev, applying || jobState === "error", livePref),
- );
- }, [applying, jobState, livePref]);
+ setHeldPref((prev) => heldUpdateBannerPref(prev, inFlight, livePref));
+ }, [inFlight, livePref]);
const showBannerPref = heldPref ?? livePref;
const show =
showBannerPref &&
visible &&
status != null &&
+ rows.length > 0 &&
(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);
+ // record every audible listed component to suppress separate cards during the quiet period.
+ if (show && tabVisible && livePref) {
+ const fresh = (recordKey.split(" ") as NotificationChannel[])
+ .filter(Boolean)
+ .filter((channel) => !shownChannels.includes(channel));
+ if (fresh.length > 0) {
+ for (const channel of fresh) {
+ markNotificationShown(channel);
+ }
+ setShownChannels([...shownChannels, ...fresh]);
+ }
+ } else if (!show && shownChannels.length > 0) {
+ setShownChannels([]);
}
- }, [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.
+ }, [show, tabVisible, livePref, recordKey, shownChannels]);
+ // a migration can reapply the automatic backend at the installed release.
const backendChange =
- status?.backend_migration_available && status.to_backend
+ llamaRow && status?.backend_migration_available && status.to_backend
? `${backendLabel(status.from_backend)} \u2192 ${backendLabel(status.to_backend)}`
: null;
- const versionChanged = llamaReleaseChanged(
- Boolean(offer?.update_available),
- installedTag,
- latestTag,
- );
- // Only the migration offer, and only the pair it was measured on: a version update
- // or a hand-picked switch keeps the plain line.
+ const llamaVersionChanged = Boolean(llamaRow?.versionChanged);
+ const backendOnly = Boolean(backendChange) && !llamaVersionChanged;
+ // show the backend pair when a migration has no version change.
+ const backendPair = backendOnly
+ ? ([
+ backendLabel(status?.from_backend),
+ backendLabel(status?.to_backend),
+ ] as const)
+ : null;
+ // only the measured migration pair gets the speed note; other updates do not.
const restartNote =
- backendChange &&
- !versionChanged &&
+ backendOnly &&
status?.from_backend === "rocm" &&
status?.to_backend === "vulkan"
? "Vulkan is >10% faster than ROCM. No restart needed after update"
: "No restart needed after update";
- const changelogKey =
- component === "llama.cpp" && versionChanged
- ? `${installedTag}\0${latestTag}`
+ const changelogTags =
+ llamaRow?.versionChanged && llamaRow.installedTag && llamaRow.latestTag
+ ? { installedTag: llamaRow.installedTag, latestTag: llamaRow.latestTag }
: null;
+ const changelogKey = changelogTags
+ ? `${changelogTags.installedTag}\0${changelogTags.latestTag}`
+ : null;
const changelogAvailable = Boolean(changelogKey && !status?.source_build);
const changelogOpen =
changelogKey !== null && changelogVersion === changelogKey;
- // Use the same predicate for the panel and its protective height floor.
+ // the panel and its protective height floor must use the same predicate.
const changelogPanelOpen = Boolean(
- !applying &&
- changelogAvailable &&
- changelogOpen &&
- installedTag &&
- latestTag,
+ !applying && changelogAvailable && changelogOpen && changelogTags,
);
- const sizeLabel =
- sizeBytes && sizeBytes > 0
- ? `${Math.round(sizeBytes / (1024 * 1024))} MB`
- : null;
+ // bundles omit a total because some components do not report a download size.
+ const sizeLabel = bundled ? null : sizeLabelOf(primary?.sizeBytes);
+ // use the phase record because migration and source-build offers disappear while jobs run.
+ const runningPhase = status?.job.runningPhase ?? null;
+ const phaseIndex = rows.findIndex(
+ (row) => updateComponentKey(row.component) === runningPhase,
+ );
+ let title: string;
+ if (applying && !bundled) {
+ title = `Updating ${label}...`;
+ } else if (applying) {
+ title =
+ phaseIndex >= 0
+ ? `Installing ${rows[phaseIndex].component} (${phaseIndex + 1} of ${rows.length})...`
+ : `Installing ${rows.length} updates...`;
+ } else if (bundled) {
+ title = `${rows.length} runtime updates`;
+ } else {
+ title = backendOnly ? `New ${label} backend` : `New ${label} update`;
+ }
const updateProgress = status?.job.progress ?? null;
const jobSucceeded = status?.job.state === "success";
- // Display value animates; aria uses the real progress.
+ // aria reports real progress while the visible value is smoothed.
const displayProgress = useSmoothedProgress(
applying,
updateProgress,
jobSucceeded,
);
- // Avoid opacity/transform transitions; GPU layer churn can flash.
+ // opacity and transform transitions can flash during gpu layer churn.
return show ? (
<div
className={cn(
@@ -293,22 +378,27 @@ export function LlamaUpdateBanner({
? "fixed bottom-4 right-4 z-[9998] w-[calc(100vw-2rem)] max-w-[calc(448px*var(--ui-space-scale,1))]"
: cn(
"pointer-events-auto flex w-[calc(100vw-2rem)] max-w-[calc(448px*var(--ui-space-scale,1))] flex-col",
- // Only an open changelog needs a shrinkable height floor.
+ // each bundled row adds one text-xs line to the open changelog's height floor.
changelogPanelOpen
- ? "min-h-[calc(117px+93px*var(--ui-font-scale,1))] max-[383px]:min-h-[calc(24px+224px*var(--ui-font-scale,1))]"
+ ? "min-h-[calc(117px+(93px+18px*var(--llama-update-extra-rows,0))*var(--ui-font-scale,1))] max-[383px]:min-h-[calc(24px+(224px+18px*var(--llama-update-extra-rows,0))*var(--ui-font-scale,1))]"
: "shrink-0",
),
)}
+ style={
+ {
+ "--llama-update-extra-rows": Math.max(rows.length - 1, 0),
+ } as CSSProperties
+ }
data-testid="llama-update-banner"
>
- {/* Paint the full floor even when the changelog content is short. */}
+ {/* fill the height floor even when the changelog content is short. */}
<div className="relative flex max-h-[calc(100dvh_-_2rem_-_var(--studio-window-chrome-top,0px))] min-h-0 grow flex-col overflow-hidden rounded-[24px] bg-white px-5 pb-4 pt-5 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.16)] dark:bg-card dark:shadow-[0_8px_28px_-6px_var(--background)]">
{applying ? null : (
<button
type="button"
onClick={dismiss}
className="absolute top-2.5 right-3 flex size-6 items-center justify-center rounded-full text-muted-foreground/60 transition-colors hover:bg-muted hover:text-foreground"
- aria-label={`Dismiss ${component} update notification`}
+ aria-label={`Dismiss ${label} update notification`}
>
<svg
aria-hidden="true"
@@ -336,32 +426,19 @@ export function LlamaUpdateBanner({
/>
<div className="min-w-0">
<p className="font-heading text-base font-medium text-foreground">
- {applying
- ? `Updating ${component}...`
- : backendChange && !versionChanged
- ? `New ${component} backend`
- : `New ${component} update`}
- </p>
- <p className="mt-0.5 text-xs text-muted-foreground">
- {versionChanged || !backendChange ? (
- <>
- {installedTag ?? "unknown"} &rarr;{" "}
- <span className="font-medium text-foreground">
- {latestTag ?? ""}
- </span>
- </>
- ) : (
- <>
- {backendLabel(status?.from_backend)} &rarr;{" "}
- <span className="font-medium text-foreground">
- {backendLabel(status?.to_backend)}
- </span>
- </>
- )}
+ {title}
</p>
+ {rows.map((row) => (
+ <VersionLine
+ key={row.component}
+ row={row}
+ bundled={bundled}
+ backendPair={row === llamaRow ? backendPair : null}
+ />
+ ))}
<p className="mt-1 text-ui-11 text-muted-foreground/70">
{sizeLabel ? `${sizeLabel} download · ` : ""}
- {versionChanged && backendChange
+ {llamaVersionChanged && backendChange
? `${backendChange} backend · `
: ""}
{restartNote}
@@ -369,10 +446,10 @@ export function LlamaUpdateBanner({
</div>
</div>
- {changelogPanelOpen && installedTag && latestTag ? (
+ {changelogPanelOpen && changelogTags ? (
<LlamaUpdateChangelogPanel
- installedTag={installedTag}
- latestTag={latestTag}
+ installedTag={changelogTags.installedTag}
+ latestTag={changelogTags.latestTag}
/>
) : null}
@@ -381,7 +458,7 @@ export function LlamaUpdateBanner({
<div
className="mb-1.5 mt-4 h-1 overflow-hidden rounded-full bg-muted"
role="progressbar"
- aria-label={`Updating ${component}`}
+ aria-label={`Updating ${label}`}
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={
@@ -414,7 +491,11 @@ export function LlamaUpdateBanner({
aria-expanded={changelogOpen}
data-testid="llama-update-changelog-toggle"
>
- {changelogOpen ? "Hide what's new" : "Show what's new"}
+ {changelogOpen
+ ? "Hide what's new"
+ : bundled
+ ? "llama.cpp changes"
+ : "Show what's new"}
</Button>
) : null}
<div className="flex flex-wrap items-center justify-end gap-x-1 gap-y-2">
@@ -429,7 +510,7 @@ export function LlamaUpdateBanner({
</Button>
<Button
size="sm"
- // Align pill edge with card padding.
+ // align the pill edge with the card padding.
className="-mr-1 h-auto whitespace-nowrap rounded-full px-3 py-2 text-ui-13"
onClick={handleUpdate}
data-testid="llama-update-button"
diff --git a/studio/frontend/src/hooks/use-llama-update-check.ts b/studio/frontend/src/hooks/use-llama-update-check.ts
index 37772602afc..1c69b1c592b 100644
--- a/studio/frontend/src/hooks/use-llama-update-check.ts
+++ b/studio/frontend/src/hooks/use-llama-update-check.ts
@@ -37,6 +37,8 @@ export interface LlamaUpdateJob {
// Set once the job leaves "running"; identifies a completed job so a
// repeated fetch of the same success can be told apart from the next one.
finished_at: string | null;
+ // The chained phase installing right now, when the backend reports phases.
+ runningPhase: "llama" | "whisper" | "audio" | null;
}
export interface ComponentOffer {
@@ -52,7 +54,7 @@ export interface LlamaUpdateStatus {
source_build: boolean;
component: "llama.cpp" | "whisper.cpp" | "audio.cpp";
// Carried per component whatever the card names: several can be behind at once,
- // and the card shows whichever one the notification switches allow.
+ // and the card lists every one the notification settings allow.
llama: ComponentOffer;
whisper: ComponentOffer | null;
// The release this Studio pins, when the managed audio.cpp runtime is another one.
@@ -100,9 +102,25 @@ function parseJob(value: unknown): LlamaUpdateJob {
progress: typeof job.progress === "number" ? job.progress : null,
started_at: typeof job.started_at === "string" ? job.started_at : null,
finished_at: typeof job.finished_at === "string" ? job.finished_at : null,
+ runningPhase: parseRunningPhase(job.phases),
};
}
+function parseRunningPhase(value: unknown): LlamaUpdateJob["runningPhase"] {
+ if (!value || typeof value !== "object") {
+ return null;
+ }
+ const phases = value as Record<
+ string,
+ { state?: unknown } | null | undefined
+ >;
+ return (
+ (["llama", "whisper", "audio"] as const).find(
+ (name) => phases[name]?.state === "running",
+ ) ?? null
+ );
+}
+
function parseOffer(offer: Record<string, unknown>): ComponentOffer {
return {
update_available: offer.update_available === true,
diff --git a/studio/frontend/src/lib/llama-job-lifecycle.ts b/studio/frontend/src/lib/llama-job-lifecycle.ts
index ae4580d5801..553807a6d5c 100644
--- a/studio/frontend/src/lib/llama-job-lifecycle.ts
+++ b/studio/frontend/src/lib/llama-job-lifecycle.ts
@@ -76,7 +76,7 @@ export interface UpdateComponentFlags {
audio: boolean;
}
-// In the order the backend names them, which is also the order the job installs them.
+// backend naming order matches the job installation order.
const UPDATE_COMPONENT_KEYS: Record<
UpdateComponent,
keyof UpdateComponentFlags
@@ -86,38 +86,64 @@ const UPDATE_COMPONENT_KEYS: Record<
"audio.cpp": "audio",
};
-/**
- * Which component's offer the single update card shows.
- *
- * Several can be pending at once and the backend names only one: llama.cpp when its
- * release is behind, then whisper.cpp, then audio.cpp, so a llama.cpp backend
- * migration is named whisper.cpp when whisper is stale too. If the named one's
- * switch is off and another 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,
+export function updateComponentKey(
+ component: UpdateComponent,
+): keyof UpdateComponentFlags {
+ return UPDATE_COMPONENT_KEYS[component];
+}
+
+/** pending components remain listed even when their notifications are muted. */
+export function updateBannerComponents(
pending: UpdateComponentFlags,
- allow: UpdateComponentFlags,
-): UpdateComponent {
- if (allow[UPDATE_COMPONENT_KEYS[named]]) {
- return named;
- }
- const other = (Object.keys(UPDATE_COMPONENT_KEYS) as UpdateComponent[]).find(
- (component) =>
- component !== named &&
- allow[UPDATE_COMPONENT_KEYS[component]] &&
- pending[UPDATE_COMPONENT_KEYS[component]],
+): UpdateComponent[] {
+ return (Object.keys(UPDATE_COMPONENT_KEYS) as UpdateComponent[]).filter(
+ (component) => pending[UPDATE_COMPONENT_KEYS[component]],
);
- return other ?? 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 or audio.cpp offer reports the release it advertised instead of llama's.
- */
+export function audibleComponents(
+ listed: readonly UpdateComponent[],
+ muted: UpdateComponentFlags,
+): UpdateComponent[] {
+ return listed.filter((component) => !muted[UPDATE_COMPONENT_KEYS[component]]);
+}
+
+/** an audible due component opens the card; it stays open until every listed component is muted. */
+export function updateBannerAllowed(
+ listed: readonly UpdateComponent[],
+ due: UpdateComponentFlags,
+ muted: UpdateComponentFlags,
+ open: boolean,
+): boolean {
+ const audible = audibleComponents(listed, muted);
+ return (
+ audible.length > 0 &&
+ (open || audible.some((component) => due[UPDATE_COMPONENT_KEYS[component]]))
+ );
+}
+
+/** holds initial rows as phases leave status; releasing the hold lets retries use remaining rows. */
+export function heldJobRows<T>(
+ held: T[] | null,
+ applying: boolean,
+ live: T[],
+): T[] | null {
+ if (!applying) {
+ return null;
+ }
+ return held ?? (live.length > 0 ? live : null);
+}
+
+export function updateComponentsLabel(
+ components: readonly UpdateComponent[],
+): string {
+ if (components.length <= 1) {
+ return components[0] ?? "llama.cpp";
+ }
+ return `${components.slice(0, -1).join(", ")} and ${components[components.length - 1]}`;
+}
+
+/** non-llama offers use their advertised tag because job `to_tag` always identifies llama.cpp. */
export function updateToastTag(
component: UpdateComponent,
jobTag: string | null | undefined,
@@ -127,15 +153,7 @@ export function updateToastTag(
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.
- */
+/** holds the opening preference because completed phases disappear during a chained job. */
export function heldUpdateBannerPref(
held: boolean | null,
inFlight: boolean,
@@ -144,14 +162,7 @@ export function heldUpdateBannerPref(
return inFlight ? (held ?? live) : null;
}
-/**
- * Whether the banner's version line has anything to say.
- *
- * `updateAvailable` is the only field reporting that the release moved. The tags cannot:
- * `installed_tag` is normalized (`b9596`) while `latest_tag` is the full identity
- * (`b9596-mix-<sha>`), so a fork install shows them differing at the release it is
- * running -- which is exactly where a migration is offered.
- */
+/** trust `updateAvailable` because installed tags are normalized but fork identities are not. */
export function llamaReleaseChanged(
updateAvailable: boolean,
installedTag: string | null,
@@ -162,12 +173,7 @@ export function llamaReleaseChanged(
);
}
-/** What to tell the user a finished Update actually did.
- *
- * A migration runs at the release already installed and can end on the backend already
- * installed, so "updated to <tag>" describes neither -- and the tag is llama's even when
- * a pending whisper update named the toast. The job's own message is accurate.
- */
+/** migration messages avoid misleading tags; null tags omit versions for bundled updates. */
export function llamaUpdateToastMessage({
component,
migrating,
@@ -178,15 +184,16 @@ export function llamaUpdateToastMessage({
component: string;
migrating: boolean;
jobMessage: string | null | undefined;
- updatedTag: string;
+ updatedTag: string | null;
reloadRequired: boolean | null | undefined;
}): string {
const reloadHint = reloadRequired ? " Reload your model to use it." : "";
const migrationMessage = migrating ? (jobMessage ?? "").trim() : "";
if (!migrationMessage) {
- return `${component} updated to ${updatedTag}.${reloadHint}`;
+ const toTag = updatedTag === null ? "" : ` to ${updatedTag}`;
+ return `${component} updated${toTag}.${reloadHint}`;
}
- // The phase appends its own reload hint when it has one to give.
+ // avoid duplicating a reload hint already supplied by the phase.
return migrationMessage.includes("Reload")
? migrationMessage
: `${migrationMessage}${reloadHint}`;
diff --git a/studio/frontend/tests/llama-job-lifecycle.test.ts b/studio/frontend/tests/llama-job-lifecycle.test.ts
index f4a2a09beed..05621ad0482 100644
--- a/studio/frontend/tests/llama-job-lifecycle.test.ts
+++ b/studio/frontend/tests/llama-job-lifecycle.test.ts
@@ -4,8 +4,12 @@
import assert from "node:assert/strict";
import test from "node:test";
import {
+ heldJobRows,
heldUpdateBannerPref,
- updateBannerComponent,
+ updateBannerAllowed,
+ updateBannerComponents,
+ updateComponentKey,
+ updateComponentsLabel,
updateToastTag,
llamaReleaseChanged,
llamaUpdateAdoptsRunningJob,
@@ -13,6 +17,10 @@ import {
llamaUpdateToastMessage,
ownedLlamaSwitchOutcome,
} from "../src/lib/llama-job-lifecycle.ts";
+import {
+ type NotificationFrequency,
+ notificationDue,
+} from "../src/hooks/use-notification-frequency.ts";
import { readSrc } from "./helpers/kit.ts";
@@ -132,7 +140,7 @@ test("a release change still needs both tags to name it", () => {
test("the banner asks the helper rather than comparing the two tags itself", () => {
const banner = readSrc("components/llama-update-banner.tsx");
- assert.match(banner, /const versionChanged = llamaReleaseChanged\(/);
+ assert.match(banner, /versionChanged: llamaReleaseChanged\(/);
assert.doesNotMatch(banner, /installedTag !== latestTag/);
});
@@ -199,14 +207,28 @@ test("an ordinary update still reports the release it moved to", () => {
);
});
-// 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
+// The job's tag is llama.cpp's, so it must not be pinned on every component a bundle names.
+test("a bundle with nothing from the job names no single release", () => {
+ assert.equal(
+ llamaUpdateToastMessage({
+ component: "llama.cpp, whisper.cpp and audio.cpp",
+ migrating: true,
+ jobMessage: "",
+ updatedTag: null,
+ reloadRequired: true,
+ }),
+ "llama.cpp, whisper.cpp and audio.cpp updated. Reload your model to use it.",
+ );
+});
+
+// The card is muted per component, and a chained apply drops llama.cpp from the
+// status when its 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.
+ // The llama phase lands and only the muted whisper.cpp is left pending.
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.
@@ -223,67 +245,157 @@ test("a muted card stays muted for a job it never showed", () => {
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, audio: false };
- const bothStale = { llama: true, whisper: true, audio: false };
- 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, audio: false }),
+// Update installs every pending component in one job, so the card lists them all.
+test("the card lists every component Update will install", () => {
+ const none = { llama: false, whisper: false, audio: false };
+ assert.deepEqual(updateBannerComponents({ llama: true, whisper: true, audio: true }), [
+ "llama.cpp",
"whisper.cpp",
+ "audio.cpp",
+ ]);
+ // One pending: the same single-component card as before.
+ assert.deepEqual(
+ updateBannerComponents({ llama: false, whisper: true, audio: false }),
+ ["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.deepEqual(updateBannerComponents(none), []);
+});
+
+test("the card names its components in install order", () => {
+ assert.equal(updateComponentsLabel(["whisper.cpp"]), "whisper.cpp");
assert.equal(
- updateBannerComponent("whisper.cpp", bothStale, { llama: true, whisper: false, audio: false }),
- "llama.cpp",
+ updateComponentsLabel(["llama.cpp", "audio.cpp"]),
+ "llama.cpp and audio.cpp",
);
- // Nothing to swap to when the other component has no offer.
assert.equal(
- updateBannerComponent(
- "llama.cpp",
- { llama: true, whisper: false, audio: false },
- { llama: false, whisper: true, audio: false },
- ),
- "llama.cpp",
+ updateComponentsLabel(["llama.cpp", "whisper.cpp", "audio.cpp"]),
+ "llama.cpp, whisper.cpp and audio.cpp",
+ );
+});
+
+test("one due component opens the card for all of them", () => {
+ const listed = ["llama.cpp", "whisper.cpp"] as const;
+ const noneMuted = { llama: false, whisper: false, audio: false };
+ assert.equal(
+ updateBannerAllowed(listed, { llama: false, whisper: true, audio: false }, noneMuted, false),
+ true,
);
- // Both muted: the name the backend gave stands, and the card stays hidden.
assert.equal(
- updateBannerComponent("llama.cpp", bothStale, { llama: false, whisper: false, audio: false }),
- "llama.cpp",
+ updateBannerAllowed(listed, { llama: false, whisper: false, audio: true }, noneMuted, false),
+ false,
+ "audio.cpp is due but has nothing listed",
+ );
+ // Open and recorded: nothing is due any more, and it stays up.
+ assert.equal(
+ updateBannerAllowed(listed, { llama: false, whisper: false, audio: false }, noneMuted, true),
+ true,
);
});
-// audio.cpp is named only when llama.cpp and whisper.cpp are not pending.
-test("an audio.cpp offer joins the switch fallback", () => {
- const allOn = { llama: true, whisper: true, audio: true };
- const audioOnly = { llama: false, whisper: false, audio: true };
- assert.equal(updateBannerComponent("audio.cpp", audioOnly, allOn), "audio.cpp");
- // Its own switch off and nothing else pending: the name stands, the card stays hidden.
+// Off means the component never asks for the card, not that the card hides it.
+test("a muted component is listed but never opens or holds the card", () => {
+ const listed = ["llama.cpp", "whisper.cpp"] as const;
+ const whisperOff = { llama: false, whisper: true, audio: false };
+ // whisper.cpp alone cannot open it, even when its clock would say due.
assert.equal(
- updateBannerComponent("audio.cpp", audioOnly, { llama: true, whisper: true, audio: false }),
- "audio.cpp",
+ updateBannerAllowed(listed, { llama: false, whisper: true, audio: false }, whisperOff, false),
+ false,
);
- // whisper.cpp named and muted, audio.cpp pending and allowed: show audio.cpp.
+ // llama.cpp opens it, and whisper.cpp rides along on the same card.
assert.equal(
- updateBannerComponent(
- "whisper.cpp",
- { llama: false, whisper: true, audio: true },
- { llama: true, whisper: false, audio: true },
- ),
- "audio.cpp",
+ updateBannerAllowed(listed, { llama: true, whisper: false, audio: false }, whisperOff, false),
+ true,
);
- // llama.cpp is preferred over audio.cpp when both could stand in.
+ // Every listed component turned off while the card is open: it goes.
assert.equal(
- updateBannerComponent(
- "whisper.cpp",
- { llama: true, whisper: true, audio: true },
- { llama: true, whisper: false, audio: true },
+ updateBannerAllowed(
+ listed,
+ { llama: false, whisper: false, audio: false },
+ { llama: true, whisper: true, audio: false },
+ true,
),
- "llama.cpp",
+ false,
+ );
+});
+
+// llama.cpp and whisper.cpp land, audio.cpp fails: the retry is for audio.cpp alone.
+test("a failed phase hands the card back to what is still pending", () => {
+ const all = ["llama.cpp", "whisper.cpp", "audio.cpp"];
+ let held = heldJobRows<string>(null, true, all);
+ assert.deepEqual(held, all);
+ // Phases land and leave the status mid-job; the card keeps naming the whole job.
+ held = heldJobRows(held, true, ["whisper.cpp", "audio.cpp"]);
+ held = heldJobRows(held, true, ["audio.cpp"]);
+ assert.deepEqual(held, all);
+ // audio.cpp fails: nothing is held, so the card shows the live rows.
+ held = heldJobRows(held, false, ["audio.cpp"]);
+ assert.equal(held, null);
+ // The retry starts from what is left.
+ held = heldJobRows(held, true, ["audio.cpp"]);
+ assert.deepEqual(held, ["audio.cpp"]);
+ // A job started elsewhere with nothing listed holds nothing.
+ assert.equal(heldJobRows<string>(null, true, []), null);
+});
+
+// The reported annoyance: the card named one component per appearance and recorded
+// only that one, so one pending job came back once per component, each on its own clock.
+function appearances(
+ listed: ReturnType<typeof updateBannerComponents>,
+ frequency: Record<"llama" | "whisper" | "audio", NotificationFrequency>,
+ launches: number[],
+): number[] {
+ const lastShown: Record<string, number | null> = {
+ llama: null,
+ whisper: null,
+ audio: null,
+ };
+ const shownAt: number[] = [];
+ for (const now of launches) {
+ const due = {
+ llama: notificationDue(frequency.llama, lastShown.llama, now),
+ whisper: notificationDue(frequency.whisper, lastShown.whisper, now),
+ audio: notificationDue(frequency.audio, lastShown.audio, now),
+ };
+ const noneMuted = { llama: false, whisper: false, audio: false };
+ if (!updateBannerAllowed(listed, due, noneMuted, false)) continue;
+ shownAt.push(now);
+ for (const component of listed) {
+ lastShown[updateComponentKey(component)] = now;
+ }
+ }
+ return shownAt;
+}
+
+test("one pending job interrupts once per quiet period, not once per component", () => {
+ const HOUR = 60 * 60 * 1000;
+ const start = 1_000_000_000_000;
+ const sameDay = [start, start + HOUR, start + 2 * HOUR, start + 3 * HOUR];
+ // Defaults, llama.cpp current, whisper.cpp and audio.cpp both behind.
+ assert.deepEqual(
+ appearances(
+ ["whisper.cpp", "audio.cpp"],
+ { llama: "always", whisper: "biweekly", audio: "biweekly" },
+ sameDay,
+ ),
+ [start],
+ );
+ // llama.cpp set to daily with all three behind.
+ assert.deepEqual(
+ appearances(
+ ["llama.cpp", "whisper.cpp", "audio.cpp"],
+ { llama: "daily", whisper: "biweekly", audio: "biweekly" },
+ sameDay,
+ ),
+ [start],
+ );
+ // The shortest quiet period still governs when the card returns.
+ assert.deepEqual(
+ appearances(
+ ["llama.cpp", "whisper.cpp"],
+ { llama: "daily", whisper: "biweekly", audio: "biweekly" },
+ [start, start + 25 * HOUR],
+ ),
+ [start, start + 25 * HOUR],
);
});
diff --git a/studio/frontend/tests/update-banner-flex-priority.test.ts b/studio/frontend/tests/update-banner-flex-priority.test.ts
index 0ae3a6de9cd..a029767da4c 100644
--- a/studio/frontend/tests/update-banner-flex-priority.test.ts
+++ b/studio/frontend/tests/update-banner-flex-priority.test.ts
@@ -191,32 +191,40 @@ test("the two update cards do not drift apart", () => {
});
test("the llama.cpp card takes the desktop updater's floor only with its changelog open", () => {
- // A collapsed changelog leaves nothing for the floor to protect.
const slot = LLAMA.slice(
LLAMA.indexOf("pointer-events-auto flex "),
LLAMA.indexOf('data-testid="llama-update-banner"'),
);
- // The constants match the desktop card, though their gates differ.
- for (const floor of [
- "min-h-[calc(117px+93px*var(--ui-font-scale,1))]",
- "min-h-[calc(24px+224px*var(--ui-font-scale,1))]",
+ // each bundled component after the first adds one 18px text-xs row to the shared floor.
+ for (const [base, text] of [
+ ["117px", "93px"],
+ ["24px", "224px"],
]) {
- assert.ok(slot.includes(floor) && TAURI.includes(floor));
+ assert.ok(
+ TAURI.includes(`min-h-[calc(${base}+${text}*var(--ui-font-scale,1))]`),
+ );
+ assert.ok(
+ slot.includes(
+ `min-h-[calc(${base}+(${text}+18px*var(--llama-update-extra-rows,0))*var(--ui-font-scale,1))]`,
+ ),
+ );
}
+ assert.match(
+ slot,
+ /"--llama-update-extra-rows":\s*Math\.max\(\s*rows\.length - 1,\s*0\s*\)/,
+ );
assert.match(slot, /max-\[383px\]:min-h-\[calc\(24px/);
assert.match(
slot,
/changelogPanelOpen\s*\n?\s*\?\s*"min-h-\[calc\(117px/,
"the floor is back on every state of the card, including the collapsed one",
);
- // The floor and panel share the same predicate.
assert.match(LLAMA, /\{changelogPanelOpen &&/);
assert.match(
slot,
/"shrink-0"/,
"with no notes to give up, the card must hold its height and let the rail scroll",
);
- // Only the conditional branch may carry a floor.
assert.doesNotMatch(classes(LLAMA, "pointer-events-auto flex "), /min-h-/);
assert.doesNotMatch(slot, /\bmin-h-0\b/);
assert.ok(LLAMA.includes("max-w-[calc(448px*var(--ui-space-scale,1))]"));
diff --git a/tests/studio/playwright_update_banner_layout.py b/tests/studio/playwright_update_banner_layout.py
index 8cfa67cc57f..3a029f5a595 100644
--- a/tests/studio/playwright_update_banner_layout.py
+++ b/tests/studio/playwright_update_banner_layout.py
@@ -212,7 +212,7 @@ LLAMA_CHANGELOG = {
"release_url": "https://github.com/unslothai/llama.cpp/releases/tag/b10333-mix-e34b418",
"error": None,
}
-# The same card, renamed: whisper.cpp is not a second banner.
+# whisper.cpp renames the shared runtime card instead of adding a banner.
WHISPER_STATUS = dict(
LLAMA_STATUS,
llama_update_available = False,
@@ -226,15 +226,27 @@ WHISPER_STATUS = dict(
"skip_reason": None,
},
)
+# pending runtimes share one card with one row each.
+BUNDLE_STATUS = dict(
+ LLAMA_STATUS,
+ whisper = WHISPER_STATUS["whisper"],
+ audio = {
+ "update_available": True,
+ "installed_tag": "v0.9.0-unsloth.1",
+ "latest_tag": "v0.9.1-unsloth.1",
+ "update_size_bytes": None,
+ "skip_reason": None,
+ },
+)
-# 921x534 and 768x500 are where the report reproduces; the taller ones prove the fix costs nothing when there is room.
+# 921x534 and 768x500 reproduce the issue; taller viewports guard roomy layouts.
VIEWPORTS = [
(1440, 900),
(1280, 830),
(921, 534),
(768, 500),
(390, 844),
- # Narrow enough to wrap the action row, short enough to hit the card's floor.
+ # narrow enough to wrap the action row and short enough to hit the card's floor.
(390, 500),
]
ROUTES = [("new chat", "/"), ("train", "/train"), ("model hub", "/model-hub")]
@@ -1241,20 +1253,34 @@ def main() -> int:
if path == "/":
exercise_llama_changelog(page, f"{size} {name}")
- # whisper.cpp renames the same card rather than adding a second one.
+ # whisper.cpp must reuse the shared runtime card.
llama_payload[0] = WHISPER_STATUS
boot(page, "/")
facts = measure(page, f"{width}x{height} new chat whisper")
+ rows = page.locator('[data-testid="llama-update-version-line"]').count()
check(
f"{width}x{height}: whisper.cpp reuses the one runtime card",
page.locator('[data-testid="llama-update-banner"]').count() <= 1
- and "whisper.cpp" in facts["llamaText"],
- f"text={facts['llamaText']!r}",
+ and "whisper.cpp" in facts["llamaText"]
+ and rows == 1,
+ f"rows={rows} text={facts['llamaText']!r}",
+ )
+
+ # pending runtimes add rows without adding cards.
+ llama_payload[0] = BUNDLE_STATUS
+ boot(page, "/")
+ facts = measure(page, f"{width}x{height} new chat bundle")
+ rows = page.locator('[data-testid="llama-update-version-line"]').count()
+ check(
+ f"{width}x{height}: three pending runtimes share the one card, a row each",
+ page.locator('[data-testid="llama-update-banner"]').count() == 1 and rows == 3,
+ f"rows={rows} text={facts['llamaText']!r}",
)
+ exercise_llama_changelog(page, f"{width}x{height} bundle")
llama_payload[0] = LLAMA_STATUS
context.close()
- # Exercise the compact app card omitted by the notes-bearing fixtures.
+ # notes-bearing fixtures omit the compact app card.
for width, height in NO_PREVIEW_VIEWPORTS[:1] if SPOT else NO_PREVIEW_VIEWPORTS:
phase(f"app card with no notes preview at {width}x{height}")
context = browser.new_context(