Skip to content

armgit / kokon

Public Imported from GitHub
0

Edit photos by describing the change, on your own GPU. A free, open-source alternative to Nano Banana and ChatGPT image editing: photos stay on your computer, no daily limit. One installer for Windows, Mac and Linux sets up the best open model (Qwen-Image 2.1). MCP server for AI agents.

What's new 0.11.1: the Mac engine, the Q4_K_M image model step, the UI fixes

Gabriele Lozuponeae8e4791a4c1
diff --git a/src/App.tsx b/src/App.tsx
index c08083c..a43285a 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -166,10 +166,9 @@ export default function App() {
tourPending.current = true;
addExampleProjects().catch(() => {});
}
- // After an app update: what's new, with the engine download when the release needs a
- // newer one (it can be postponed there; offered again only for another release).
+ // After an app update: what's new, with the engine and model downloads the release offers
+ // (they can be postponed there). Closing it goes on with afterStartScreens.
const whatsNew = cfg.setupComplete && whatsNewDue(ui, st?.engine);
- const engineUpdate = whatsNew && !!st?.engine?.update_needed;
// Otherwise, once on a Mac: Kokon's Mac engine (before the model loads, on the engine chosen).
const macOffer = !inBrowser && welcomeSeen && !whatsNew && macEngineOfferDue(st, ui, cfg.setupComplete);
setState({ needsSetup: !cfg.setupComplete, ...(!welcomeSeen ? { overlay: "welcome" } : whatsNew ? { overlay: "whats-new" } : macOffer ? { overlay: "mac-engine" } : {}) });
@@ -181,8 +180,9 @@ export default function App() {
const w = m.active.source === "user" ? m.slots.find((x) => x.role === "diffusion")?.info?.warning : null;
if (w) toastError(new ApiError({ code: "model_warning", message: w, suggestion: "Settings → Models: download the official files, or use other files of your own." }, 200));
}, () => {});
- // Preload the model so the first generation starts immediately (not an engine about to be replaced).
- if (cfg.setupComplete && !engineUpdate && !macOffer && st && st.server.state === "stopped") api.startBackend().then(refreshStatus, () => refreshStatus());
+ // Preload the model so the first generation starts immediately. After What's new or the Mac offer instead
+ // (afterStartScreens): not a file or engine about to be replaced, and on the engine the user picks.
+ if (cfg.setupComplete && !whatsNew && !macOffer && st && st.server.state === "stopped") api.startBackend().then(refreshStatus, () => refreshStatus());
} catch (e) {
setBoot(String(e));
}
diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx
index b517a2c..ae1f5d7 100644
--- a/src/components/Settings.tsx
+++ b/src/components/Settings.tsx
@@ -11,7 +11,7 @@ import { LoraSettings } from "./LoraSettings";
import { RemoteAccess } from "./RemoteAccess";
import { UpscalerControls } from "./Upscalers";
import { WHATS_NEW_VERSION } from "./WhatsNew";
-import type { AppConfig, Check, MacBenchState, ModelProfile, ModelsStatus, SetupReport, TextEncoderPlacement } from "../lib/types";
+import type { AppConfig, Check, InstallStatus, MacBenchState, ModelProfile, ModelsStatus, SetupReport, TextEncoderPlacement } from "../lib/types";
import { IconButton, Seg, Switch } from "./ui";
import { autoCheckEnabled, checkForUpdate } from "../lib/updates";
@@ -312,29 +312,33 @@ export function Settings() {
}
};
- // Switching to the new VAE (#21): download, then the service swaps it and deletes the old one.
+ // Switching to the new VAE (#21) or the Q4_K_M image model: download, then the service swaps it and deletes the old
+ // file from Kokon's folder (never the user's own).
const [vaeProgress, setVaeProgress] = useState<number | null>(null);
- const improveVae = async () => {
+ const [ditProgress, setDitProgress] = useState<number | null>(null);
+ const switchFile = async (start: () => Promise<InstallStatus>, setProgress: (p: number | null) => void, done: string) => {
try {
- let st = await api.improveVae();
- setVaeProgress(0);
+ let st = await start();
+ setProgress(0);
while (st.running) {
await new Promise((r) => window.setTimeout(r, 700));
st = await api.installStatus();
const total = st.items.reduce((a, i) => a + i.size, 0);
- setVaeProgress(total ? st.items.reduce((a, i) => a + i.received, 0) / total : 0);
+ setProgress(total ? st.items.reduce((a, i) => a + i.received, 0) / total : 0);
}
const failed = st.items.find((i) => i.state === "failed");
if (failed) toastError(new Error(`${failed.label}: ${failed.error}`));
- else if (st.complete) toastInfo("The new decoder is in use");
+ else if (st.complete) toastInfo(done);
api.models().then(setMs, () => {});
api.config().then(setCfg, () => {});
} catch (e) {
toastError(e);
} finally {
- setVaeProgress(null);
+ setProgress(null);
}
};
+ const improveVae = () => switchFile(api.improveVae, setVaeProgress, "The new decoder is in use");
+ const newImageModel = () => switchFile(api.newImageModel, setDitProgress, "The Q4_K_M image model is in use");
const close = () => setState({ overlay: null });
useEffect(() => {
@@ -610,6 +614,26 @@ export function Settings() {
<PathField label="Vision projector (mmproj)" value={profile.visionProjector ?? ""} onChange={(v) => setProfile({ visionProjector: v || null })} />
</>
)}
+ {ms?.dit.update && (
+ <div className="setting-card">
+ <div className="setting-card-text">
+ <strong>Image model file</strong>
+ <span className="muted">
+ {ms.dit.update === "official"
+ ? "Kokon now uses unsloth's Q4_K_M of the image model: better supported, slightly better, the same 4-bit size. Switching downloads it and deletes the old file from Kokon's folder."
+ : "Your image model is the Q4_K file Kokon used before. Kokon now uses unsloth's Q4_K_M: better supported, slightly better, the same 4-bit size. Switching downloads it into Kokon's folder; your own file stays where it is."}
+ </span>
+ {ditProgress !== null && (
+ <div className="progress" style={{ marginTop: 6 }}>
+ <i style={{ width: `${ditProgress * 100}%` }} />
+ </div>
+ )}
+ </div>
+ <button className="btn primary" disabled={ditProgress !== null || vaeProgress !== null || dirty} title={dirty ? "Save or discard your changes first" : undefined} onClick={newImageModel}>
+ <Download size={15} /> {ditProgress !== null ? `${Math.floor(ditProgress * 100)}%` : `Switch${ms.dit.download_bytes ? ` · ${formatBytes(ms.dit.download_bytes)}` : ""}`}
+ </button>
+ </div>
+ )}
{ms && (
<div className="setting-card">
<div className="setting-card-text">
@@ -627,7 +651,7 @@ export function Settings() {
)}
</div>
{!ms.vae.improved && (
- <button className="btn primary" disabled={vaeProgress !== null || dirty} title={dirty ? "Save or discard your changes first" : undefined} onClick={improveVae}>
+ <button className="btn primary" disabled={vaeProgress !== null || ditProgress !== null || dirty} title={dirty ? "Save or discard your changes first" : undefined} onClick={improveVae}>
<Download size={15} /> {vaeProgress !== null ? `${Math.floor(vaeProgress * 100)}%` : `Switch${ms.vae.download_bytes ? ` · ${formatBytes(ms.vae.download_bytes)}` : ""}`}
</button>
)}
diff --git a/src/components/WhatsNew.tsx b/src/components/WhatsNew.tsx
index 4386367..7e8df99 100644
--- a/src/components/WhatsNew.tsx
+++ b/src/components/WhatsNew.tsx
@@ -1,53 +1,50 @@
-import { CircleAlert, Container, FolderSync, ShieldCheck, Smartphone, TabletSmartphone } from "lucide-react";
+import { CircleAlert, Copy, Cpu, Expand, Image, MousePointerClick } from "lucide-react";
import { useEffect, useState } from "react";
import { api } from "../lib/api";
-import { formatBytes, installProgress, installStep, installTimeLeft } from "../lib/logic";
+import { formatBytes, installProgress, installStep, installTimeLeft, modelChoiceUi, modelOfferDue, whatsNewDue as due } from "../lib/logic";
+import { inBrowser } from "../lib/platform";
import { afterStartScreens, refreshStatus, setState, toastError, useStore } from "../lib/store";
import type { GpuBackend, InstallItem, InstallStatus, ModelsStatus } from "../lib/types";
import { KokonMark } from "./Welcome";
/** The release these notes describe. Shown once to people updating from an earlier version. */
-export const WHATS_NEW_VERSION = "0.11.0";
+export const WHATS_NEW_VERSION = "0.11.1";
+
+const MAC_NEWS = {
+ icon: Cpu,
+ title: "Kokon's own Mac engine",
+ text: "An engine made by Kokon for Apple Silicon: about 4 times faster on an M2 Pro, for new images, edits, brushed edits, extending and Prompt+. It's experimental and off until you try it; switch back any time in Settings → Performance.",
+};
const NEWS = [
{
- icon: Smartphone,
- title: "Kokon on your phone",
- text: "Open Settings → Other devices, choose a password and scan the QR code: a phone, a tablet or another computer on your network uses Kokon in its browser. The images are still made on this computer and kept in its gallery.",
- },
- {
- icon: TabletSmartphone,
- title: "Made for a phone screen",
- text: "On a phone Kokon has a layout of its own: your projects as the home screen, versions you swipe through, a screen of its own for writing the prompt, and an icon for the home screen.",
- },
- {
- icon: FolderSync,
- title: "The same projects everywhere",
- text: "Every device sees the same list of projects: a version made on the phone shows up in that project on the computer.",
+ icon: Image,
+ title: "A new copy of the image model",
+ text: "New installs get unsloth's Q4_K_M of Qwen-Image 2.1 Turbo: the same model in the same 4-bit size, better supported and slightly better. If you have the earlier file, Kokon asks before changing it.",
},
{
- icon: ShieldCheck,
- title: "Off until you turn it on",
- text: "Nothing listens on the network before you set a password, each browser asks for it once, and five wrong tries make that device wait. From outside your home, use Tailscale or another VPN (guide in the docs).",
+ icon: Expand,
+ title: "Expand to a ratio and a size",
+ text: "Expand can lock the aspect ratio and offers 1080p, 1440p and 4K. The size menu has the same sizes, and an exact size you typed can be picked again.",
},
{
- icon: Container,
- title: "Docker and Linux servers",
- text: "Kokon without a window, for NVIDIA cards: the Docker image ghcr.io/gabrielelozupone/kokon, or kokon-service --remote on a Linux machine.",
+ icon: Copy,
+ title: "Copy from the info panel",
+ text: "The prompt, seed and settings of an image can be selected, and each has a copy button.",
},
{
- icon: CircleAlert,
- title: "Your own model files",
- text: "Kokon warns when the image model is the base Qwen-Image 2.1 instead of Turbo (Kokon runs Turbo's 8 steps), and the MCP server works with folders listed in QLS_MCP_ALLOWED_DIRS.",
+ icon: MousePointerClick,
+ title: "Smaller fixes",
+ text: "Reuse keeps a fixed seed instead of picking a new one, and selected text is visible again in the dark theme on Linux.",
},
];
-/** Remembers that these notes were read and, if the engine update was postponed, for which
- * release, so neither is offered again at the next start. */
-async function markSeen(engineSkipped: string | null) {
+/** Remembers that these notes were read and what was postponed (the engine update for its release, the model step),
+ * so neither is offered again at the next start. */
+async function markSeen(engineSkipped: string | null, model: Record<string, unknown>) {
try {
const cfg = await api.config();
- const ui: Record<string, unknown> = { ...((cfg.ui ?? {}) as Record<string, unknown>), whatsNewSeen: WHATS_NEW_VERSION };
+ const ui: Record<string, unknown> = { ...((cfg.ui ?? {}) as Record<string, unknown>), whatsNewSeen: WHATS_NEW_VERSION, ...model };
if (engineSkipped) ui.engineUpdateSkipped = engineSkipped;
await api.saveConfig({ ...cfg, ui });
} catch (e) {
@@ -55,33 +52,35 @@ async function markSeen(engineSkipped: string | null) {
}
}
-/** Whether to show the notes at start: once per release after an update (not on a new install,
- * which gets the welcome screen), and again while a needed engine update was not postponed. */
+/** Whether to show the notes at start (see `logic.whatsNewDue`). */
export function whatsNewDue(ui: Record<string, unknown>, engine: { release: string; update_needed: boolean } | undefined): boolean {
- if (!ui.welcomeSeen) return false;
- return ui.whatsNewSeen !== WHATS_NEW_VERSION || (!!engine?.update_needed && ui.engineUpdateSkipped !== engine.release);
+ return due(ui, engine, WHATS_NEW_VERSION);
}
-type Step = "engine" | "vae";
+type Step = "engine" | "vae" | "model";
-/** What's new in this release, plus the downloads it offers: the engine when the release needs
- * a newer stable-diffusion.cpp (only the files that changed), and the new VAE (#21), which
- * replaces the old one only if the user accepts. */
+/** What's new in this release, plus the downloads it offers, each chosen separately: the engine when the release needs
+ * a newer stable-diffusion.cpp (only the files that changed), the new VAE (#21) and the Q4_K_M image model, which
+ * replace the old files only if the user accepts. Own model files are never switched: the model step is a suggestion. */
export function WhatsNew() {
const engine = useStore((s) => s.status?.engine);
+ const macEngine = useStore((s) => !!s.status?.mac_engine?.available) && !inBrowser;
const needsEngine = !!engine?.update_needed;
const [missing, setMissing] = useState<InstallItem[] | null>(null);
const [target, setTarget] = useState<{ preset: string; backend: GpuBackend } | null>(null);
const [ms, setMs] = useState<ModelsStatus | null>(null);
- // With both offered, each can be left out.
+ const [ui, setUi] = useState<Record<string, unknown> | null>(null);
+ // With several offered, each can be left out.
const [wantEngine, setWantEngine] = useState(true);
const [wantVae, setWantVae] = useState(true);
+ const [wantModel, setWantModel] = useState(true);
const [queue, setQueue] = useState<Step[]>([]);
const [inst, setInst] = useState<InstallStatus | null>(null);
const [finished, setFinished] = useState(false);
useEffect(() => {
api.models().then(setMs, () => {});
+ api.config().then((c) => setUi((c.ui ?? {}) as Record<string, unknown>), () => setUi({}));
api.installStatus().then((i) => i.running && setInst(i), () => {});
if (!needsEngine) return;
api.hardware().then((h) => {
@@ -94,16 +93,21 @@ export function WhatsNew() {
}, [needsEngine]);
const offerVae = !!ms && !ms.vae.improved;
+ const offerModel = !!ui && modelOfferDue(ms?.dit, ui, WHATS_NEW_VERSION);
+ const ownModel = ms?.dit.update === "own";
const engineBytes = (missing ?? []).reduce((a, i) => a + Math.max(0, i.size - i.received), 0);
const vaeBytes = ms?.vae.download_bytes ?? 0;
+ const modelBytes = ms?.dit.download_bytes ?? 0;
const begin = async (step: Step) => {
try {
if (step === "engine") {
if (!target) return false;
setInst(await api.install(target.preset, target.backend, false));
- } else {
+ } else if (step === "vae") {
setInst(await api.improveVae());
+ } else {
+ setInst(await api.newImageModel());
}
return true;
} catch (e) {
@@ -137,12 +141,18 @@ export function WhatsNew() {
const items = inst?.items ?? [];
const failed = items.filter((i) => i.state === "failed");
const prog = installProgress(items);
- const steps: Step[] = [...(needsEngine && wantEngine ? ["engine" as const] : []), ...(offerVae && wantVae ? ["vae" as const] : [])];
- const size = (steps.includes("engine") ? engineBytes : 0) + (steps.includes("vae") ? vaeBytes : 0);
- const offering = (needsEngine || offerVae) && !finished;
+ // Smallest first; the image model last.
+ const steps: Step[] = [
+ ...(needsEngine && wantEngine ? ["engine" as const] : []),
+ ...(offerVae && wantVae ? ["vae" as const] : []),
+ ...(offerModel && wantModel ? ["model" as const] : []),
+ ];
+ const size = (steps.includes("engine") ? engineBytes : 0) + (steps.includes("vae") ? vaeBytes : 0) + (steps.includes("model") ? modelBytes : 0);
+ const offering = (needsEngine || offerVae || offerModel) && !finished;
// Macs default to Lanczos: their update has no Superscale-SP download.
const getsSuperscale = (missing ?? []).some((i) => i.id === "upscaler_superscale");
- const both = needsEngine && offerVae;
+ const several = [needsEngine, offerVae, offerModel].filter(Boolean).length > 1;
+ const modelOnly = offerModel && !several;
const update = async () => {
const [first, ...rest] = steps;
@@ -150,10 +160,13 @@ export function WhatsNew() {
setQueue(rest);
await begin(first);
};
- const close = (postponed: boolean) => {
+ /** `keep`: an own-files user chose to keep their image model (never asked again). */
+ const close = (postponed: boolean, keep = false) => {
if (running) api.cancelInstall().catch(() => {});
setState({ overlay: null });
- markSeen(postponed && engine && needsEngine ? engine.release : null);
+ // A model step that did not happen (postponed or left out) waits for the next release.
+ const modelUi = offerModel && (postponed || !wantModel) ? modelChoiceUi(keep ? "keep" : "later", WHATS_NEW_VERSION) : {};
+ markSeen(postponed && engine && needsEngine ? engine.release : null, modelUi);
refreshStatus();
afterStartScreens();
};
@@ -164,7 +177,7 @@ export function WhatsNew() {
<KokonMark size={44} />
<h1>What's new in Kokon {WHATS_NEW_VERSION}</h1>
<div className="welcome-grid">
- {NEWS.map(({ icon: Icon, title, text }) => (
+ {(macEngine ? [MAC_NEWS, ...NEWS] : NEWS).map(({ icon: Icon, title, text }) => (
<div className="welcome-item" key={title}>
<Icon size={20} />
<strong>{title}</strong>
@@ -175,9 +188,33 @@ export function WhatsNew() {
{offering && !running && (
<div className="update-offers">
+ {offerModel && (
+ <div className="setup-note update-offer">
+ {several && <input type="checkbox" checked={wantModel} onChange={(e) => setWantModel(e.target.checked)} aria-label="Include the new image model file" />}
+ <div>
+ <strong>
+ {ownModel ? "A newer image model file" : "New image model file"}
+ {modelBytes ? ` · ${formatBytes(modelBytes)}` : ""}
+ </strong>
+ <span>
+ {ownModel
+ ? "Your image model is the Q4_K file Kokon used before. Kokon now uses unsloth's Q4_K_M: better supported, slightly better, the same 4-bit size. Kokon can download it into its own folder and use it; your file stays where it is, untouched."
+ : "Kokon now uses unsloth's Q4_K_M of Qwen-Image 2.1 Turbo: better supported, slightly better, the same 4-bit size. The old file is deleted once the new one is downloaded and checked."}{" "}
+ You can also switch later in Settings → Models.
+ </span>
+ <details className="model-files">
+ <summary>Why change it?</summary>
+ <span className="update-detail">
+ Both are 4-bit copies of Qwen's Turbo model and look much the same. The Q4_K_M comes from unsloth, one of the most used sources of
+ GGUF models, and it is the file Kokon's tests and its Mac engine are checked against. Same license as the model.
+ </span>
+ </details>
+ </div>
+ </div>
+ )}
{offerVae && (
<div className="setup-note update-offer">
- {both && <input type="checkbox" checked={wantVae} onChange={(e) => setWantVae(e.target.checked)} aria-label="Include the new decoder" />}
+ {several && <input type="checkbox" checked={wantVae} onChange={(e) => setWantVae(e.target.checked)} aria-label="Include the new decoder" />}
<div>
<strong>New image decoder{vaeBytes ? ` · ${formatBytes(vaeBytes)}` : ""}</strong>
<span>
@@ -198,7 +235,7 @@ export function WhatsNew() {
)}
{needsEngine && (
<div className="setup-note update-offer">
- {both && <input type="checkbox" checked={wantEngine} onChange={(e) => setWantEngine(e.target.checked)} aria-label="Include the engine update" />}
+ {several && <input type="checkbox" checked={wantEngine} onChange={(e) => setWantEngine(e.target.checked)} aria-label="Include the engine update" />}
<div>
<strong>Engine update{engineBytes ? ` · ${formatBytes(engineBytes)}` : ""}</strong>
<span>
@@ -241,10 +278,14 @@ export function WhatsNew() {
<div className="welcome-actions">
<div className="welcome-buttons">
<button className="btn primary big" disabled={running || !steps.length || (steps.includes("engine") && (!target || missing === null))} onClick={update}>
- {failed.length ? "Try again" : running ? "Updating…" : `Update now${size ? ` · ${formatBytes(size)}` : ""}`}
+ {failed.length
+ ? "Try again"
+ : running
+ ? "Updating…"
+ : `${modelOnly ? (ownModel ? "Download Q4_K_M and use it" : "Update now and remove the old file") : "Update now"}${size ? ` · ${formatBytes(size)}` : ""}`}
</button>
- <button className="btn big" onClick={() => close(true)}>
- {offerVae && !needsEngine ? "Keep the current one" : "Later"}
+ <button className="btn big" onClick={() => close(true, modelOnly && ownModel)}>
+ {modelOnly && ownModel ? "Keep using my file" : offerVae && !needsEngine && !offerModel ? "Keep the current one" : "Later"}
</button>
</div>
<span className="muted welcome-foot">You can update later from Settings → Models.</span>
diff --git a/src/lib/api.ts b/src/lib/api.ts
index 1b24a65..bbb5068 100644
--- a/src/lib/api.ts
+++ b/src/lib/api.ts
@@ -107,6 +107,7 @@ export const api = {
useModels: (profile: "official" | "user") => call<ModelsStatus>("/models/use", { method: "POST", body: json({ profile }) }),
/** Downloads the texture-fix VAE and switches the active model to it (progress in installStatus). */
improveVae: () => call<InstallStatus>("/models/vae", { method: "POST" }),
+ newImageModel: () => call<InstallStatus>("/models/dit", { method: "POST" }),
/** Runs the engine on another card (index in `hardware().gpus`); needs the engine installed. */
setGpu: (gpu: number) => call<{ saved: boolean }>("/setup/gpu", { method: "POST", body: json({ gpu }) }),
upscalers: () => call<{ selected: string; active: string | null; items: UpscalerItem[] }>("/upscalers"),
diff --git a/src/lib/logic.test.ts b/src/lib/logic.test.ts
index 6f132df..54daecd 100644
--- a/src/lib/logic.test.ts
+++ b/src/lib/logic.test.ts
@@ -1,6 +1,9 @@
import { describe, expect, it } from "vitest";
import {
macEngineOfferDue,
+ modelChoiceUi,
+ modelOfferDue,
+ whatsNewDue,
macBenchProgress,
activeLoras, activeOverrides, buildRequest, composing, editing, reviewRequest, wantsPromptReview, toggleLora, MAX_LORAS, jobPercent, compareBase, composerFromRecord, enhancerApplies, diffPixels, emptyComposer, expansionPixels, expansionPreset, jobLabel, jobSecondsLeft, lutInfo, moveRef, needsPrompt, normalizeQuality, persistentAdvanced, pipelineSummary,
planPipeline, remainingSeconds, sizeForWidth, timeAgo, upscaleRequest, upscaleTargets, versionLabels, type JobClock, type Ref,
@@ -654,3 +657,37 @@ describe("macEngineOfferDue", () => {
expect(macEngineOfferDue({ gpu: null, mac_engine: undefined }, {}, true)).toBe(false);
});
});
+
+describe("whatsNewDue", () => {
+ const engine = (update_needed: boolean) => ({ release: "r2", update_needed });
+ it("once per release after an update, never on a new install", () => {
+ expect(whatsNewDue({ welcomeSeen: true, whatsNewSeen: "0.11.0" }, engine(false), "0.11.1")).toBe(true);
+ expect(whatsNewDue({ welcomeSeen: true, whatsNewSeen: "0.11.1" }, engine(false), "0.11.1")).toBe(false);
+ expect(whatsNewDue({}, engine(true), "0.11.1")).toBe(false);
+ });
+ it("again while a needed engine update was not postponed", () => {
+ expect(whatsNewDue({ welcomeSeen: true, whatsNewSeen: "0.11.1" }, engine(true), "0.11.1")).toBe(true);
+ expect(whatsNewDue({ welcomeSeen: true, whatsNewSeen: "0.11.1", engineUpdateSkipped: "r2" }, engine(true), "0.11.1")).toBe(false);
+ });
+});
+
+describe("modelOfferDue", () => {
+ const dit = (update: "official" | "own" | null) => ({ update, download_bytes: 4_199_565_120, page: "" });
+ it("offers the Q4_K_M to the official files on the Q4_K until accepted, Later waiting for the next release", () => {
+ expect(modelOfferDue(dit("official"), {}, "0.11.1")).toBe(true);
+ const later = modelChoiceUi("later", "0.11.1");
+ expect(modelOfferDue(dit("official"), later, "0.11.1")).toBe(false);
+ expect(modelOfferDue(dit("official"), later, "0.12.0")).toBe(true);
+ expect(modelOfferDue(dit(null), {}, "0.11.1")).toBe(false);
+ expect(modelOfferDue(undefined, {}, "0.11.1")).toBe(false);
+ });
+ it("own files: a suggestion only when they are the old Q4_K; keeping them is final", () => {
+ expect(modelOfferDue(dit("own"), {}, "0.11.1")).toBe(true);
+ const keep = modelChoiceUi("keep", "0.11.1");
+ expect(modelOfferDue(dit("own"), keep, "0.11.1")).toBe(false);
+ expect(modelOfferDue(dit("own"), keep, "0.12.0")).toBe(false);
+ expect(modelOfferDue(dit("own"), modelChoiceUi("later", "0.11.1"), "0.12.0")).toBe(true);
+ // Already the Q4_K_M, or another file of theirs: the service reports nothing to offer.
+ expect(modelOfferDue(dit(null), {}, "0.11.1")).toBe(false);
+ });
+});
diff --git a/src/lib/logic.ts b/src/lib/logic.ts
index 5019037..603147f 100644
--- a/src/lib/logic.ts
+++ b/src/lib/logic.ts
@@ -1,6 +1,6 @@
// Pure UI logic (unit-tested in logic.test.ts).
-import type { Advanced, GenerationRecord, GenerationRequest, InpaintAction, InputRecord, InstallItem, JobView, LoraItem, LutInfo, MacBenchState, Mode, StatusResponse, OutpaintSpec, Plan, Quality, ResolutionMode, Size } from "./types";
+import type { Advanced, GenerationRecord, GenerationRequest, InpaintAction, InputRecord, InstallItem, JobView, LoraItem, LutInfo, MacBenchState, Mode, ModelsStatus, StatusResponse, OutpaintSpec, Plan, Quality, ResolutionMode, Size } from "./types";
export interface Ref {
key: string;
@@ -643,6 +643,28 @@ export function formatBytes(n: number): string {
return `${Math.max(0, Math.round(n / 1e3))} KB`;
}
+/** Whether What's new shows at start: once per release `version` after an update (not on a new install, which gets the
+ * welcome screen), and again while a needed engine update was not postponed. */
+export function whatsNewDue(ui: Record<string, unknown>, engine: { release: string; update_needed: boolean } | undefined, version: string): boolean {
+ if (!ui.welcomeSeen) return false;
+ return ui.whatsNewSeen !== version || (!!engine?.update_needed && ui.engineUpdateSkipped !== engine.release);
+}
+
+/** The image-model step of What's new (the Q4_K_M, 0.11.1): offered to the official files still on the Q4_K and, as a
+ * suggestion, to own files that are that Q4_K. "Later" waits for the next release `version`; "Keep using my file" is
+ * never asked again. */
+export function modelOfferDue(dit: ModelsStatus["dit"] | undefined, ui: Record<string, unknown>, version: string): boolean {
+ if (!dit?.update) return false;
+ if (dit.update === "own" && ui.ownModelKept) return false;
+ return ui.modelUpdateSkipped !== version;
+}
+
+/** What closing What's new remembers about a model step it offered and that did not happen: "keep" (own files) for
+ * good, otherwise postponed until the next release `version`. */
+export function modelChoiceUi(choice: "later" | "keep", version: string): Record<string, unknown> {
+ return choice === "keep" ? { ownModelKept: true } : { modelUpdateSkipped: version };
+}
+
/** Offer Kokon's Mac engine once, at start: set up, the engine in the app, off, never asked. Not below 16 GB: the
* engine peaks at ~9 GB during a 1024² decode (M2 Pro, Benchmark button 2026-10-26) and was never run on 8 GB. */
export function macEngineOfferDue(st: Pick<StatusResponse, "gpu" | "mac_engine"> | null, ui: Record<string, unknown>, setupComplete: boolean): boolean {
diff --git a/src/lib/types.ts b/src/lib/types.ts
index 94eefdc..dd9c394 100644
--- a/src/lib/types.ts
+++ b/src/lib/types.ts
@@ -405,6 +405,9 @@ export interface ModelsStatus {
default_download_dir: string;
/** The texture-fix VAE (#21): in use, or what switching to it downloads. */
vae: { improved: boolean; download_bytes: number; page: string };
+ /** The Q4_K_M image model (0.11.1): "official" for the official files still on the Q4_K, "own" for own files that are
+ * that Q4_K (a suggestion only), null otherwise; and what switching downloads. */
+ dit: { update: "official" | "own" | null; download_bytes: number; page: string };
}
export interface HardwareReport {