Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Add app update controls

Bittiffc2b128b724
diff --git a/src/App.tsx b/src/App.tsx
index 5dbe36a..9a2aa95 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -12,6 +12,8 @@ import { ProjectCard } from "./components/ProjectCard";
import { ProjectWorkspace, type ProjectView } from "./components/ProjectWorkspace";
import { PromptComposer } from "./components/PromptComposer";
import { SettingsView } from "./components/SettingsView";
+import { UpdatePanel, UpdateProgress } from "./components/UpdatePanel";
+import { AppUpdater } from "./lib/updater";
import { describeDiagnosticError, errorContext, writeDiagnostic } from "./lib/diagnostics";
import { chooseAndOpenProject, createProject, deleteProject, isTauri, listRecentProjects, saveProject } from "./lib/persistence";
import type { CreateProjectInput, ProjectRecord } from "./lib/project";
@@ -57,6 +59,20 @@ function App() {
the engine paths, and the Generator would otherwise go on reporting the
missing weights the user just pointed it at until they reopened it. */
const [settingsOpen, setSettingsOpen] = useState(false);
+ const [settingsInitialTab, setSettingsInitialTab] = useState<"engine" | "updates">("engine");
+ const [updater] = useState(() => new AppUpdater());
+ const updateState = useSyncExternalStore(updater.subscribe, updater.getSnapshot);
+ useEffect(() => { void updater.start(); }, [updater]);
+ const updateGuard = useRef<() => string | null>(() => null);
+ updateGuard.current = () => activeProject
+ ? "Close your project before installing an update."
+ : loading || busy || deletingProject || newProjectOpen || projectToDelete
+ ? "Finish the current project action before installing an update."
+ : workQueue.updateBlockReason();
+ const updateBlockReason = useCallback(() => updateGuard.current(), []);
+ const updatePanel = <UpdatePanel updater={updater} blockReason={updateBlockReason} />;
+ const updateNotice = ["available", "restart"].includes(updateState.stage) && !settingsOpen
+ ? <button className="secondary-button update-notice" onClick={() => { setSettingsInitialTab("updates"); setSettingsOpen(true); }}>{updateState.stage === "restart" ? "Restart to finish updating Slopus" : `Slopus ${updateState.version} is available`}</button> : null;
const [settingsRevision, setSettingsRevision] = useState(0);
const closeSettings = () => { setSettingsOpen(false); setSettingsRevision((value) => value + 1); };
/* What is installed on this computer. Probed ONCE here rather than every
@@ -159,6 +175,7 @@ function App() {
}, [projects, query]);
const openFromFolder = async () => {
+ setBusy(true);
setError(null);
try {
const project = await chooseAndOpenProject();
@@ -169,6 +186,8 @@ function App() {
} catch (reason) {
logFailure("project.open_failed", reason);
setError({ title: "Couldn’t open that folder", detail: describe(reason) });
+ } finally {
+ setBusy(false);
}
};
@@ -215,7 +234,7 @@ function App() {
paths it holds are what makes generation work at all, and finding out they
are wrong happens inside a project, not in the library. */
const settingsLauncher = (
- <button className="settings-launcher" type="button" onClick={() => setSettingsOpen(true)} title="Settings" aria-label="Settings">
+ <button className="settings-launcher" type="button" onClick={() => { setSettingsInitialTab("engine"); setSettingsOpen(true); }} title="Settings" aria-label="Settings">
<Settings size={22} aria-hidden="true" />
</button>
);
@@ -233,7 +252,9 @@ function App() {
{settingsLauncher}
{queueLauncher}
{queuePanel}
- {settingsOpen && <SettingsView onClose={closeSettings} />}
+ {settingsOpen && <SettingsView onClose={closeSettings} updates={updatePanel} initialTab={settingsInitialTab} />}
+ {updateNotice}
+ <UpdateProgress updater={updater} />
{iconConfirmation}
{exitGuard}
</>;
@@ -287,7 +308,9 @@ function App() {
{queueLauncher}
{queuePanel}
{newProjectOpen && <PromptComposer busy={busy} onCreate={createFromPrompt} onClose={() => setNewProjectOpen(false)} />}
- {settingsOpen && <SettingsView onClose={closeSettings} />}
+ {settingsOpen && <SettingsView onClose={closeSettings} updates={updatePanel} initialTab={settingsInitialTab} />}
+ {updateNotice}
+ <UpdateProgress updater={updater} />
{projectToDelete && <DeleteProjectDialog project={projectToDelete} deleting={deletingProject} onConfirm={() => void confirmProjectDeletion()} onCancel={() => setProjectToDelete(null)} />}
{iconConfirmation}
{exitGuard}
diff --git a/src/components/SettingsView.test.tsx b/src/components/SettingsView.test.tsx
index dadf6ce..3805a62 100644
--- a/src/components/SettingsView.test.tsx
+++ b/src/components/SettingsView.test.tsx
@@ -101,7 +101,7 @@ describe("the settings screen", () => {
it("swaps panels when a tab is chosen, and follows the arrow keys", () => {
open();
expect(screen.getAllByRole("tab").map((item) => item.textContent?.replace(/\d+$/, ""))).toEqual([
- "Video engine", "Agents", "Appearance", "Diagnostics",
+ "Video engine", "Agents", "Appearance", "Diagnostics", "Updates",
]);
fireEvent.click(tab("Appearance"));
expect(screen.getByRole("radiogroup", { name: "Appearance" })).toBeTruthy();
diff --git a/src/components/SettingsView.tsx b/src/components/SettingsView.tsx
index 4f9a2eb..1032977 100644
--- a/src/components/SettingsView.tsx
+++ b/src/components/SettingsView.tsx
@@ -1,5 +1,5 @@
import { AlertCircle, Check, ChevronLeft, FileText, FolderOpen, FolderSearch, LoaderCircle, Monitor, Moon, Plus, RefreshCw, RotateCcw, Sun, Trash2, X } from "lucide-react";
-import { useCallback, useEffect, useState, useSyncExternalStore } from "react";
+import { useCallback, useEffect, useState, useSyncExternalStore, type ReactNode } from "react";
import { getDiagnosticLogInfo, revealDiagnosticLog, type DiagnosticLogInfo } from "../lib/diagnostics";
import { isTauri } from "../lib/persistence";
import { chooseEnginePath, getAgentModels, getEngineStatus, type ModelStatus, type SlopfabStatus } from "../lib/runtime";
@@ -248,14 +248,15 @@ const TABS = [
{ id: "llms", label: "Agents" },
{ id: "appearance", label: "Appearance" },
{ id: "diagnostics", label: "Diagnostics" },
+ { id: "updates", label: "Updates" },
] as const;
type TabId = (typeof TABS)[number]["id"];
-export function SettingsView({ onClose }: { onClose: () => void }) {
+export function SettingsView({ onClose, updates, initialTab = "engine" }: { onClose: () => void; updates?: ReactNode; initialTab?: TabId }) {
/* The engine first: this screen exists because those paths have to be set
before anything can be rendered, and its status line answers "is Slopus
ready?" without a click. */
- const [tab, setTab] = useState<TabId>("engine");
+ const [tab, setTab] = useState<TabId>(initialTab);
const [templateSettings, setTemplateSettings] = useState<GeneratorTemplateSettings>(() => loadGeneratorTemplateSettings());
const [editingTemplateId, setEditingTemplateId] = useState<string | null>(null);
const [status, setStatus] = useState<SlopfabStatus | null>(null);
@@ -406,6 +407,9 @@ export function SettingsView({ onClose }: { onClose: () => void }) {
</div>}
<div className="settings-view__body">
+ {tab === "updates" && <section className="settings-section" id="settings-panel-updates" role="tabpanel" aria-labelledby="settings-tab-updates">
+ {updates ?? <p>Updates are available in the desktop app.</p>}
+ </section>}
{tab === "llms" && <section
className="settings-section"
id="settings-panel-llms"
diff --git a/src/components/UpdatePanel.test.tsx b/src/components/UpdatePanel.test.tsx
new file mode 100644
index 0000000..d811bf5
--- /dev/null
+++ b/src/components/UpdatePanel.test.tsx
@@ -0,0 +1,46 @@
+// @vitest-environment jsdom
+import "@testing-library/jest-dom/vitest";
+import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { afterEach, expect, it, vi } from "vitest";
+import type { DownloadEvent } from "@tauri-apps/plugin-updater";
+import { AppUpdater } from "../lib/updater";
+import { UpdatePanel, UpdateProgress } from "./UpdatePanel";
+
+afterEach(cleanup);
+function setup() {
+ const update = { version: "0.2.0", body: "<b>Release notes</b>", download: vi.fn(async (_listener?: (event: DownloadEvent) => void) => {}), install: vi.fn(async () => {}), close: vi.fn(async () => {}) };
+ const updater = new AppUpdater({ enabled: async () => true, check: async () => update, relaunch: vi.fn(async () => {}) });
+ return { updater, update };
+}
+
+it("shows release notes as text and blocks installation when a project is open", async () => {
+ const { updater, update } = setup();
+ await updater.start();
+ const view = render(<UpdatePanel updater={updater} blockReason={() => "Close your project before installing an update."} />);
+ expect(screen.getByText("<b>Release notes</b>").querySelector("b")).toBeNull();
+ expect(screen.getByRole("button", { name: "Install and restart" })).toBeDisabled();
+ view.rerender(<UpdatePanel updater={updater} blockReason={() => null} />);
+ fireEvent.click(screen.getByRole("button", { name: "Install and restart" }));
+ await waitFor(() => expect(update.install).toHaveBeenCalledOnce());
+});
+
+it("shows download progress in a blocking dialog and restores controls after failure", async () => {
+ const { updater, update } = setup();
+ await updater.start();
+ let rejectDownload!: (reason: Error) => void;
+ update.download.mockImplementationOnce((listener) => {
+ listener?.({ event: "Started", data: {} });
+ listener?.({ event: "Progress", data: { chunkLength: 1048576 } });
+ return new Promise((_resolve, reject) => { rejectDownload = reject; });
+ });
+ render(<><UpdatePanel updater={updater} blockReason={() => null} /><UpdateProgress updater={updater} /></>);
+ fireEvent.click(screen.getByRole("button", { name: "Install and restart" }));
+ expect(screen.getByRole("dialog", { name: "Updating Slopus" })).toHaveFocus();
+ expect(screen.getByText("1.0 MB downloaded")).toBeInTheDocument();
+ expect(screen.getByRole("progressbar")).not.toHaveAttribute("value");
+ await act(async () => { rejectDownload(new Error("Network disconnected")); });
+ expect(screen.queryByRole("dialog")).toBeNull();
+ expect(screen.getByRole("alert")).toHaveTextContent("Network disconnected");
+ expect(screen.getByRole("button", { name: "Install and restart" })).toBeEnabled();
+ expect(update.install).not.toHaveBeenCalled();
+});
diff --git a/src/components/UpdatePanel.tsx b/src/components/UpdatePanel.tsx
new file mode 100644
index 0000000..0429ab9
--- /dev/null
+++ b/src/components/UpdatePanel.tsx
@@ -0,0 +1,38 @@
+import { useSyncExternalStore } from "react";
+import type { AppUpdater } from "../lib/updater";
+
+export function UpdatePanel({ updater, blockReason }: { updater: AppUpdater; blockReason: () => string | null }) {
+ const state = useSyncExternalStore(updater.subscribe, updater.getSnapshot);
+ const busy = ["checking", "downloading", "installing"].includes(state.stage);
+ const blocked = blockReason();
+ return <div className="update-panel">
+ <h2>App updates</h2>
+ <p>Slopus checks for updates each time it starts. You choose when to install and restart.</p>
+ <p role="status">{state.stage === "disabled" ? "Updates are available in installed release builds. Download a new portable version to update a portable copy."
+ : state.stage === "checking" ? "Checking for updates…"
+ : state.stage === "current" ? "You’re up to date."
+ : state.stage === "restart" ? "Update installed. Restart Slopus to finish."
+ : state.version ? `Slopus ${state.version} is available.` : "Check for a new version of Slopus."}</p>
+ {state.notes && <pre className="update-panel__notes">{state.notes}</pre>}
+ {state.error && <p role="alert">{state.error}</p>}
+ {state.version && blocked && <p>{blocked}</p>}
+ <div className="update-panel__actions">
+ <button type="button" className="secondary-button" disabled={busy || state.stage === "disabled" || state.stage === "restart"} onClick={() => void updater.check()}>Check for updates</button>
+ {state.version && state.stage !== "restart" && <button type="button" className="primary-button" disabled={busy || Boolean(blocked)} onClick={() => void updater.install(blockReason)}>Install and restart</button>}
+ {state.stage === "restart" && <button type="button" className="primary-button" disabled={Boolean(blocked)} onClick={() => void updater.restart(blockReason)}>Restart Slopus</button>}
+ </div>
+ </div>;
+}
+
+export function UpdateProgress({ updater }: { updater: AppUpdater }) {
+ const state = useSyncExternalStore(updater.subscribe, updater.getSnapshot);
+ if (state.stage !== "downloading" && state.stage !== "installing") return null;
+ const percent = state.total ? Math.min(100, Math.round(state.downloaded / state.total * 100)) : undefined;
+ return <div className="update-progress" role="dialog" aria-modal="true" aria-label="Updating Slopus" tabIndex={-1} ref={(node) => node?.focus()} onKeyDown={(event) => { event.stopPropagation(); if (event.key === "Tab") event.preventDefault(); }}>
+ <div className="update-panel">
+ <h2>{state.stage === "downloading" ? "Downloading update…" : "Installing update…"}</h2>
+ <p role="status">{state.stage === "downloading" ? (percent === undefined ? `${(state.downloaded / 1048576).toFixed(1)} MB downloaded` : `${percent}% downloaded`) : "Slopus will restart when the update is ready."}</p>
+ <progress aria-label="Update download" max={100} value={state.stage === "downloading" ? percent : undefined} />
+ </div>
+ </div>;
+}
diff --git a/src/lib/updater.test.ts b/src/lib/updater.test.ts
new file mode 100644
index 0000000..eb7c39f
--- /dev/null
+++ b/src/lib/updater.test.ts
@@ -0,0 +1,112 @@
+import { describe, expect, it, vi } from "vitest";
+import type { DownloadEvent } from "@tauri-apps/plugin-updater";
+import { AppUpdater } from "./updater";
+
+function setup(enabled = true) {
+ const update = {
+ version: "0.2.0", body: "A better editor",
+ download: vi.fn(async (_listener?: (event: DownloadEvent) => void) => {}),
+ install: vi.fn(async () => {}), close: vi.fn(async () => {}),
+ };
+ const dependencies = { enabled: vi.fn(async () => enabled), check: vi.fn(async () => update as typeof update | null), relaunch: vi.fn(async () => {}) };
+ return { updater: new AppUpdater(dependencies), update, dependencies };
+}
+
+describe("app updates", () => {
+ it("checks once on startup and waits for explicit installation", async () => {
+ const { updater, update, dependencies } = setup();
+ await Promise.all([updater.start(), updater.start()]);
+ expect(dependencies.check).toHaveBeenCalledTimes(1);
+ expect(updater.getSnapshot()).toMatchObject({ stage: "available", version: "0.2.0", notes: "A better editor" });
+ expect(update.download).not.toHaveBeenCalled();
+ expect(dependencies.relaunch).not.toHaveBeenCalled();
+ });
+
+ it("does not check in a browser, debug build or portable distribution", async () => {
+ const { updater, dependencies } = setup(false);
+ await updater.start();
+ await updater.check();
+ expect(dependencies.check).not.toHaveBeenCalled();
+ expect(updater.getSnapshot().stage).toBe("disabled");
+ });
+
+ it("reports no update and releases old native resources when checking again", async () => {
+ const { updater, update, dependencies } = setup();
+ await updater.start();
+ dependencies.check.mockResolvedValueOnce(null);
+ await updater.check();
+ expect(update.close).toHaveBeenCalledOnce();
+ expect(updater.getSnapshot()).toMatchObject({ stage: "current", version: null, notes: "" });
+ });
+
+ it("recovers from an offline check", async () => {
+ const { updater, dependencies } = setup();
+ dependencies.check.mockRejectedValueOnce(new Error("Offline"));
+ await updater.start();
+ expect(updater.getSnapshot().error).toContain("Offline");
+ await updater.check();
+ expect(updater.getSnapshot()).toMatchObject({ stage: "available", error: null });
+ });
+
+ it("blocks installation while a project or background work needs attention", async () => {
+ const { updater, update } = setup();
+ await updater.start();
+ await updater.install(() => "Save your work first.");
+ expect(update.download).not.toHaveBeenCalled();
+ expect(updater.getSnapshot().error).toBe("Save your work first.");
+ });
+
+ it("tracks downloads and installs before restarting, ignoring concurrent actions", async () => {
+ const { updater, update, dependencies } = setup();
+ await updater.start();
+ update.download.mockImplementationOnce(async (listener) => {
+ listener?.({ event: "Started", data: { contentLength: 100 } });
+ listener?.({ event: "Progress", data: { chunkLength: 40 } });
+ listener?.({ event: "Progress", data: { chunkLength: 60 } });
+ expect(updater.getSnapshot()).toMatchObject({ stage: "downloading", downloaded: 100, total: 100 });
+ await updater.check();
+ await updater.install(() => null);
+ expect(update.install).not.toHaveBeenCalled();
+ });
+ await updater.install(() => null);
+ expect(update.download).toHaveBeenCalledOnce();
+ expect(dependencies.check).toHaveBeenCalledOnce();
+ expect(update.install).toHaveBeenCalledOnce();
+ expect(update.install.mock.invocationCallOrder[0]).toBeLessThan(dependencies.relaunch.mock.invocationCallOrder[0]);
+ expect(updater.getSnapshot().stage).toBe("restart");
+ });
+
+ it("rechecks work before launching the installer", async () => {
+ const { updater, update, dependencies } = setup();
+ await updater.start();
+ const guard = vi.fn<() => string | null>().mockReturnValueOnce(null).mockReturnValue("Work started during download.");
+ await updater.install(guard);
+ expect(update.install).not.toHaveBeenCalled();
+ expect(dependencies.relaunch).not.toHaveBeenCalled();
+ expect(updater.getSnapshot()).toMatchObject({ stage: "available", error: "Work started during download." });
+ });
+
+ it("never installs or restarts on a download or signature verification failure", async () => {
+ const { updater, update, dependencies } = setup();
+ await updater.start();
+ update.download.mockRejectedValueOnce(new Error("Invalid signature"));
+ await updater.install(() => null);
+ expect(update.install).not.toHaveBeenCalled();
+ expect(dependencies.relaunch).not.toHaveBeenCalled();
+ expect(updater.getSnapshot()).toMatchObject({ stage: "available", error: "Invalid signature" });
+ await updater.install(() => null);
+ expect(update.install).toHaveBeenCalledOnce();
+ });
+
+ it("allows restart retry without reinstalling an already installed update", async () => {
+ const { updater, update, dependencies } = setup();
+ await updater.start();
+ dependencies.relaunch.mockRejectedValueOnce(new Error("Restart failed"));
+ await updater.install(() => null);
+ expect(updater.getSnapshot()).toMatchObject({ stage: "restart", error: "Restart failed" });
+ await updater.restart(() => null);
+ expect(update.install).toHaveBeenCalledOnce();
+ expect(dependencies.relaunch).toHaveBeenCalledTimes(2);
+ expect(updater.getSnapshot().error).toBeNull();
+ });
+});
diff --git a/src/lib/updater.ts b/src/lib/updater.ts
new file mode 100644
index 0000000..20eebf4
--- /dev/null
+++ b/src/lib/updater.ts
@@ -0,0 +1,101 @@
+import { invoke } from "@tauri-apps/api/core";
+import { relaunch } from "@tauri-apps/plugin-process";
+import { check, type Update } from "@tauri-apps/plugin-updater";
+import { isTauri } from "./persistence";
+
+type Stage = "disabled" | "idle" | "checking" | "current" | "available" | "downloading" | "installing" | "restart";
+interface UpdaterState {
+ stage: Stage;
+ version: string | null;
+ notes: string;
+ downloaded: number;
+ total: number | undefined;
+ error: string | null;
+}
+type UpdateHandle = Pick<Update, "version" | "body" | "download" | "install" | "close">;
+interface UpdaterDependencies {
+ enabled: () => Promise<boolean>;
+ check: () => Promise<UpdateHandle | null>;
+ relaunch: () => Promise<void>;
+}
+const native: UpdaterDependencies = {
+ enabled: async () => isTauri() && await invoke<boolean>("app_updater_enabled"),
+ check: () => check({ timeout: 15_000 }),
+ relaunch,
+};
+const describe = (reason: unknown) => reason instanceof Error ? reason.message : String(reason);
+
+/** App-owned state survives Settings closing and React StrictMode effects. */
+export class AppUpdater {
+ private state: UpdaterState = { stage: "disabled", version: null, notes: "", downloaded: 0, total: undefined, error: null };
+ private listeners = new Set<() => void>();
+ private update: UpdateHandle | null = null;
+ private started = false;
+ private busy = false;
+ constructor(private dependencies: UpdaterDependencies = native) {}
+ getSnapshot = () => this.state;
+ subscribe = (listener: () => void) => { this.listeners.add(listener); return () => { this.listeners.delete(listener); }; };
+ private publish(patch: Partial<UpdaterState>) {
+ this.state = { ...this.state, ...patch };
+ this.listeners.forEach((listener) => listener());
+ }
+ start = async () => {
+ if (this.started) return;
+ this.started = true;
+ try {
+ if (!await this.dependencies.enabled()) return;
+ this.publish({ stage: "idle" });
+ await this.check();
+ } catch (reason) {
+ this.publish({ error: describe(reason) });
+ }
+ };
+ check = async () => {
+ if (this.busy || this.state.stage === "disabled" || this.state.stage === "restart") return;
+ this.busy = true;
+ this.publish({ stage: "checking", error: null });
+ try {
+ if (this.update) await this.update.close();
+ this.update = null;
+ this.publish({ version: null, notes: "" });
+ this.update = await this.dependencies.check();
+ this.publish({ stage: this.update ? "available" : "current", version: this.update?.version ?? null, notes: this.update?.body ?? "" });
+ } catch (reason) {
+ this.publish({ stage: this.update ? "available" : "idle", error: `Could not check for updates. ${describe(reason)}` });
+ } finally { this.busy = false; }
+ };
+ install = async (blockReason: () => string | null) => {
+ if (this.busy || !this.update || this.state.stage !== "available") return;
+ const blocked = blockReason();
+ if (blocked) { this.publish({ error: blocked }); return; }
+ this.busy = true;
+ this.publish({ stage: "downloading", error: null, downloaded: 0, total: undefined });
+ let installed = false;
+ try {
+ await this.update.download((event) => {
+ if (event.event === "Started") this.publish({ total: event.data.contentLength });
+ if (event.event === "Progress") this.publish({ downloaded: this.state.downloaded + event.data.chunkLength });
+ }, { timeout: 120_000 });
+ // A background job may have started while the download was in flight.
+ const nowBlocked = blockReason();
+ if (nowBlocked) throw new Error(nowBlocked);
+ this.publish({ stage: "installing" });
+ await this.update.install();
+ installed = true;
+ this.publish({ stage: "restart" });
+ await this.dependencies.relaunch();
+ } catch (reason) {
+ this.publish({ stage: installed ? "restart" : "available", error: describe(reason) });
+ } finally { this.busy = false; }
+ };
+ restart = async (blockReason: () => string | null) => {
+ if (this.busy || this.state.stage !== "restart") return;
+ const blocked = blockReason();
+ if (blocked) { this.publish({ error: blocked }); return; }
+ this.busy = true;
+ this.publish({ error: null });
+ try { await this.dependencies.relaunch(); }
+ catch (reason) { this.publish({ error: describe(reason) }); }
+ finally { this.busy = false; }
+ };
+}
diff --git a/src/lib/workQueue.test.ts b/src/lib/workQueue.test.ts
index f8fb9b5..75d49ec 100644
--- a/src/lib/workQueue.test.ts
+++ b/src/lib/workQueue.test.ts
@@ -47,6 +47,14 @@ const finish = async (queue: WorkQueue, id: string) => {
};
describe("application work queue", () => {
+ it("blocks app updates for unsaved sessions and allows them after a successful save", async () => {
+ const { queue, first } = setup();
+ expect(queue.updateBlockReason()).toBeNull();
+ first.update((config) => ({ ...config, name: "Unsaved title" }));
+ expect(queue.updateBlockReason()).toContain("Save your project");
+ await first.save();
+ expect(queue.updateBlockReason()).toBeNull();
+ });
it("isolates identical scene IDs across projects and freezes inputs before any asynchronous preparation", async () => {
const { queue, first, second } = setup();
saveEngineSettings({ ...EMPTY_ENGINE_SETTINGS, transformer: "C:/original-model" });
diff --git a/src/lib/workQueue.ts b/src/lib/workQueue.ts
index 4cf868b..0cc73b2 100644
--- a/src/lib/workQueue.ts
+++ b/src/lib/workQueue.ts
@@ -72,6 +72,16 @@ export class WorkQueue {
constructor(private writer: ProjectWriter = saveProject) {}
getSnapshot = () => this.items;
+ updateBlockReason = (): string | null => {
+ if (this.items.some(isWorkActive) || this.icons.confirmationCount() > 0) {
+ return "Finish or cancel queued work before installing an update.";
+ }
+ if (this.items.some((item) => item.needsSave) || [...this.projects.values()].some((session) => {
+ const state = session.getSnapshot();
+ return state.dirty || state.saving || state.saveError;
+ })) return "Save your project changes and generated videos before installing an update.";
+ return null;
+ };
getIconConfirmationCount = () => this.icons.confirmationCount();
answerIconConfirmation = (confirmed: boolean, remember: boolean) => this.icons.answerConfirmation(confirmed, remember);
subscribe = (listener: () => void) => { this.listeners.add(listener); return () => { this.listeners.delete(listener); }; };
diff --git a/src/styles/index.css b/src/styles/index.css
index 23f4949..35e4ae0 100644
--- a/src/styles/index.css
+++ b/src/styles/index.css
@@ -25,6 +25,7 @@
@import "./references.css";
@import "./export.css";
@import "./exit-guard.css";
+@import "./updater.css";
/* Body text entry uses one reading size. Editable inspector headings keep
their own hierarchy below. */
diff --git a/src/styles/updater.css b/src/styles/updater.css
new file mode 100644
index 0000000..448d55c
--- /dev/null
+++ b/src/styles/updater.css
@@ -0,0 +1,9 @@
+.update-panel { display: grid; gap: var(--space-4); }
+.update-panel h2, .update-panel p { margin: 0; }
+.update-panel p { font-size: var(--text-base); line-height: var(--leading-normal); }
+.update-panel__notes { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; max-height: 240px; overflow: auto; }
+.update-panel__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
+.update-notice { position: fixed; right: var(--space-6); bottom: var(--space-6); z-index: 30; }
+.update-progress { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; background: var(--bg); }
+.update-progress .update-panel { width: min(480px, 90vw); padding: var(--space-6); background: var(--panel); border-radius: var(--radius-lg); }
+.update-progress progress { width: 100%; }