AI media harness for planning, generating, and editing locally
TypeScript
Use manual updates for portable builds
Bittid3f216ea17e7
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex 10b726a..1dc79a9 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -14,6 +14,8 @@ This alpha update adds DMAD LoRA support, resumable model downloads, and improve## Fixes and improvements+- Portable builds show available updates and open GitHub releases for manual updating instead of running an installer.+- Simplified image edits and added references for individual edits. Still-image generation receives only the references mentioned in its prompt, with clear image and RefMod identifiers.- Removed box coordinates and palettes from image prompts, and limited image controls to supported generator model types.- Improved image family deletion so removing a variant preserves its original. Selected image boxes can also be deleted from the canvas.diff --git a/docs/updater.md b/docs/updater.mdindex 2924b54..9d71db1 100644--- a/docs/updater.md+++ b/docs/updater.md@@ -6,10 +6,19 @@ is explicit and restarts Slopus. Close the project and finish or cancel queuedwork first; unsaved project changes or videos also block installation. Failedchecks and downloads can be retried from Settings.-Browser previews, debug builds, and folders containing the `slopus-portable`-marker do not check for updates. Both packaging scripts add this marker only to-the uncompressed folder for local testing, after creating the ZIP. The distributed-ZIP omits the marker, so extracted release builds can check for updates.+Browser previews and debug builds do not check for updates. Portable release+builds include a `slopus-portable` marker beside `Slopus.exe`, both in the ZIP+and in the unpacked build folder. They check on startup and in Settings, show+available versions and release notes, and offer **Open releases** to open+https://github.com/bitti-ai/slopus/releases in the default browser. They never+download or run an installer, and opening the page does not require closing a+project or stopping background work.++To update a portable copy, download the newer portable ZIP, close Slopus, and+replace `Slopus.exe` and `slopfab.dll` together in the existing folder. Keep the+`slopus-portable` marker beside the executable. Settings, projects and downloaded+models are preserved. Older portable ZIPs omitted this marker; update those+copies manually once to receive the corrected update behavior.## Pre-release testsdiff --git a/package.cmd b/package.cmdindex 9dd31ed..26cc23d 100644--- a/package.cmd+++ b/package.cmd@@ -106,11 +106,10 @@ echo Folder: %OUTPUT_STEM%-portable\echo.echo [5/5] Creating the portable archive...-rem Archive without the marker so distributed copies can check for updates.-powershell.exe -NoProfile -NonInteractive -Command "$ErrorActionPreference='Stop'; Compress-Archive -Path (Join-Path $env:OUTPUT_DIR '*') -DestinationPath $env:OUTPUT_ZIP -CompressionLevel Optimal -Force" || goto :fail-rem Disable updates only in the unpacked folder used for local testing.-> "%OUTPUT_DIR%\slopus-portable" echo Local test build - automatic updates disabled.+rem Include the marker so portable copies offer manual updates from GitHub.+> "%OUTPUT_DIR%\slopus-portable" echo Portable build - download updates from https://github.com/bitti-ai/slopus/releasesif errorlevel 1 goto :fail+powershell.exe -NoProfile -NonInteractive -Command "$ErrorActionPreference='Stop'; Compress-Archive -Path (Join-Path $env:OUTPUT_DIR '*') -DestinationPath $env:OUTPUT_ZIP -CompressionLevel Optimal -Force" || goto :failecho.echo Package complete.@@ -131,6 +130,10 @@ exit /b 0>>"%~1" echo.>>"%~1" echo Run "Slopus.exe". Projects are folders you choose on disk.>>"%~1" echo.+>>"%~1" echo UPDATES+>>"%~1" echo Download the latest portable ZIP from https://github.com/bitti-ai/slopus/releases+>>"%~1" echo Close Slopus, then replace Slopus.exe and slopfab.dll together in this folder.+>>"%~1" echo.>>"%~1" echo REQUIREMENTS>>"%~1" echo Microsoft Edge WebView2. Use the setup installer if it is missing.>>"%~1" echo.diff --git a/release.cmd b/release.cmdindex e3df820..359e6ca 100644--- a/release.cmd+++ b/release.cmd@@ -159,11 +159,10 @@ echo Folder: %OUTPUT_STEM%-portable\echo.echo [6/6] Creating the portable archive...-rem Archive without the marker so distributed copies can check for updates.-powershell.exe -NoProfile -NonInteractive -Command "$ErrorActionPreference='Stop'; Compress-Archive -Path (Join-Path $env:OUTPUT_DIR '*') -DestinationPath $env:OUTPUT_ZIP -CompressionLevel Optimal -Force" || goto :fail-rem Disable updates only in the unpacked folder used for local testing.-> "%OUTPUT_DIR%\slopus-portable" echo Local test build - automatic updates disabled.+rem Include the marker so portable copies offer manual updates from GitHub.+> "%OUTPUT_DIR%\slopus-portable" echo Portable build - download updates from https://github.com/bitti-ai/slopus/releasesif errorlevel 1 goto :fail+powershell.exe -NoProfile -NonInteractive -Command "$ErrorActionPreference='Stop'; Compress-Archive -Path (Join-Path $env:OUTPUT_DIR '*') -DestinationPath $env:OUTPUT_ZIP -CompressionLevel Optimal -Force" || goto :failecho.echo Package complete.@@ -206,6 +205,10 @@ exit /b 1>>"%~1" echo.>>"%~1" echo Run "Slopus.exe". Projects are folders you choose on disk.>>"%~1" echo.+>>"%~1" echo UPDATES+>>"%~1" echo Download the latest portable ZIP from https://github.com/bitti-ai/slopus/releases+>>"%~1" echo Close Slopus, then replace Slopus.exe and slopfab.dll together in this folder.+>>"%~1" echo.>>"%~1" echo REQUIREMENTS>>"%~1" echo Microsoft Edge WebView2. Use the setup installer if it is missing.>>"%~1" echo.diff --git a/src-tauri/src/app.rs b/src-tauri/src/app.rsindex 4e4c15d..2e625d4 100644--- a/src-tauri/src/app.rs+++ b/src-tauri/src/app.rs@@ -4,18 +4,18 @@ use crate::{slopfab, weights, window,};use std::io;-/// Portable distributions carry a marker because Windows updates launch an-/// installer and cannot replace a portable folder in place.+/// Portable copies check for updates but open the release page for manual updates.#[tauri::command]-fn app_updater_enabled() -> bool {- !cfg!(debug_assertions)- && std::env::current_exe()- .ok()- .and_then(|exe| {- exe.parent()- .map(|dir| !dir.join("slopus-portable").exists())- })- .unwrap_or(false)+fn app_updater_mode() -> Result<&'static str, String> {+ if cfg!(debug_assertions) { return Ok("disabled"); }+ let exe = std::env::current_exe().map_err(|error| error.to_string())?;+ let directory = exe.parent().ok_or("Could not locate the application folder.")?;+ Ok(if directory.join("slopus-portable").exists() { "portable" } else { "installed" })+}++#[tauri::command]+fn open_app_releases() -> Result<(), String> {+ crate::external_links::open_browser("https://github.com/bitti-ai/slopus/releases")}#[cfg_attr(mobile, tauri::mobile_entry_point)]@@ -174,7 +174,8 @@ pub fn run() {commands::artifacts::save_generated_image,commands::artifacts::open_image_source,commands::artifacts::export_generated_image,- app_updater_enabled,+ app_updater_mode,+ open_app_releases,weights::download_weight,weights::lora::prepare_lora,weights::cancel_weight_download,diff --git a/src-tauri/src/cuda_support.rs b/src-tauri/src/cuda_support.rsindex 525cec0..9a61b7b 100644--- a/src-tauri/src/cuda_support.rs+++ b/src-tauri/src/cuda_support.rs@@ -13,28 +13,7 @@ fn download_url(version: &str) -> Result<&'static str, String> {pub fn open_cuda_download(version: String) -> Result<(), String> {// Only these two download pages can be opened by this command.let url = download_url(&version)?;- #[cfg(windows)]- {- use windows_sys::Win32::UI::Shell::ShellExecuteW;- let operation: Vec<u16> = "open\0".encode_utf16().collect();- let target: Vec<u16> = url.encode_utf16().chain(Some(0)).collect();- // Both strings are NUL-terminated and remain alive for the shell call.- let result = unsafe {- ShellExecuteW(std::ptr::null_mut(), operation.as_ptr(), target.as_ptr(),- std::ptr::null(), std::ptr::null(), 1)- };- if result as isize <= 32 {- return Err("Could not open the browser. Copy the download link into your browser.".into());- }- Ok(())- }- #[cfg(not(windows))]- {- let program = if cfg!(target_os = "macos") { "open" } else { "xdg-open" };- std::process::Command::new(program).arg(url).spawn()- .map(|_| ())- .map_err(|error| format!("Could not open the browser: {error}"))- }+ crate::external_links::open_browser(url)}#[cfg(test)]diff --git a/src-tauri/src/external_links.rs b/src-tauri/src/external_links.rsnew file mode 100644index 0000000..b0f919f--- /dev/null+++ b/src-tauri/src/external_links.rs@@ -0,0 +1,25 @@+/// Open a trusted application-owned URL in the default browser.+pub(crate) fn open_browser(url: &str) -> Result<(), String> {+ #[cfg(windows)]+ {+ use windows_sys::Win32::UI::Shell::ShellExecuteW;+ let operation: Vec<u16> = "open\0".encode_utf16().collect();+ let target: Vec<u16> = url.encode_utf16().chain(Some(0)).collect();+ // Both strings are NUL-terminated and remain alive for the shell call.+ let result = unsafe {+ ShellExecuteW(std::ptr::null_mut(), operation.as_ptr(), target.as_ptr(),+ std::ptr::null(), std::ptr::null(), 1)+ };+ if result as isize <= 32 {+ return Err("Could not open the browser. Copy the download link into your browser.".into());+ }+ Ok(())+ }+ #[cfg(not(windows))]+ {+ let program = if cfg!(target_os = "macos") { "open" } else { "xdg-open" };+ std::process::Command::new(program).arg(url).spawn()+ .map(|_| ())+ .map_err(|error| format!("Could not open the browser: {error}"))+ }+}diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 659d631..d93b5cb 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -7,6 +7,7 @@ mod conditioning;mod cuda_support;mod diagnostics;mod export;+mod external_links;mod generation;mod media;mod native_shell;diff --git a/src/components/UpdatePanel.test.tsx b/src/components/UpdatePanel.test.tsxindex 64d9e23..ed8796c 100644--- a/src/components/UpdatePanel.test.tsx+++ b/src/components/UpdatePanel.test.tsx@@ -7,12 +7,40 @@ import { AppUpdater } from "../lib/updater";import { lastCheckedLabel, UpdateInfoBar, UpdatePanel } from "./UpdatePanel";afterEach(cleanup);-function setup() {+function setup(mode: "installed" | "portable" = "installed") {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 };+ const openReleases = vi.fn(async () => {});+ const updater = new AppUpdater({ mode: async () => mode, openReleases, check: async () => update, relaunch: vi.fn(async () => {}) });+ return { updater, update, openReleases };}+it("offers manual portable updates even while a project is open", async () => {+ const { updater, update, openReleases } = setup("portable");+ await updater.start();+ render(<UpdatePanel updater={updater} blockReason={() => "Close your project first."} />);+ expect(screen.getByRole("heading", { name: "Slopus 0.2.0 is available" })).toBeInTheDocument();+ expect(screen.queryByText("Close your project first.")).toBeNull();+ expect(screen.queryByRole("button", { name: "Install and restart" })).toBeNull();+ expect(screen.getByText(/download the latest portable ZIP/)).toBeInTheDocument();+ const button = screen.getByRole("button", { name: "Open releases" });+ expect(button).toBeEnabled();+ fireEvent.click(button);+ await waitFor(() => expect(openReleases).toHaveBeenCalledOnce());+ expect(update.download).not.toHaveBeenCalled();+ expect(update.install).not.toHaveBeenCalled();+});++it("opens releases directly from the portable update notification", async () => {+ const { updater, openReleases } = setup("portable");+ await updater.start();+ const onOpen = vi.fn();+ render(<UpdateInfoBar updater={updater} onOpen={onOpen} />);+ expect(screen.getByRole("status")).toHaveTextContent("Slopus 0.2.0 is available to download.");+ fireEvent.click(screen.getByRole("button", { name: "Open releases" }));+ await waitFor(() => expect(openReleases).toHaveBeenCalledOnce());+ expect(onOpen).not.toHaveBeenCalled();+});+it("shows the available version, release notes as text, and blocks installation when a project is open", async () => {const { updater, update } = setup();await updater.start();diff --git a/src/components/UpdatePanel.tsx b/src/components/UpdatePanel.tsxindex d411196..ab94b4d 100644--- a/src/components/UpdatePanel.tsx+++ b/src/components/UpdatePanel.tsx@@ -51,7 +51,7 @@ function statusTitle(state: UpdaterState): string {export function UpdatePanel({ updater, blockReason, onOpenReleaseNotes }: { updater: AppUpdater; blockReason: () => string | null; onOpenReleaseNotes?: () => void }) {const state = useSyncExternalStore(updater.subscribe, updater.getSnapshot);const busy = ["checking", "downloading", "installing"].includes(state.stage);- const blocked = blockReason();+ const blocked = state.mode === "portable" ? null : blockReason();const transferring = state.stage === "downloading" || state.stage === "installing";const glyph: ReactNode = state.stage === "checking" ? <ProgressRing size={32} aria-label="Checking for updates" />@@ -64,7 +64,7 @@ export function UpdatePanel({ updater, blockReason, onOpenReleaseNotes }: { upda: state.stage === "restart"? <button type="button" className="primary-button" disabled={Boolean(blocked)} onClick={() => void updater.restart(blockReason)}>Restart Slopus</button>: state.stage === "available"- ? <button type="button" className="primary-button" disabled={busy || Boolean(blocked)} onClick={() => void updater.install(blockReason)}>Install and restart</button>+ ? <button type="button" className="primary-button" disabled={busy || Boolean(blocked)} onClick={() => void updater.install(blockReason)}>{state.mode === "portable" ? "Open releases" : "Install and restart"}</button>: <button type="button" className="secondary-button" disabled={busy} onClick={() => void updater.check()}>Check for updates</button>;return (@@ -76,10 +76,11 @@ export function UpdatePanel({ updater, blockReason, onOpenReleaseNotes }: { upda<span className="update-card__caption">Current version {APP_VERSION} ({APP_CHANNEL})</span><span className="update-card__caption">{state.stage === "disabled"- ? "Installed release builds update themselves. To update a portable copy, download the new version."+ ? "Update checks are available in release builds.": state.stage === "installing" ? "Slopus restarts when the update is ready.": lastCheckedLabel(state.lastChecked)}</span>+ {state.mode === "portable" && <span className="update-card__caption">To update this portable copy, download the latest portable ZIP from GitHub, close Slopus, and replace its application files.</span>}{state.stage === "downloading" && <><span className="update-card__caption update-card__progress-label">{downloadedLabel(state)}</span><ProgressBar value={percentOf(state)} aria-label="Update download" className="update-card__progress" />@@ -109,8 +110,9 @@ export function UpdatePanel({ updater, blockReason, onOpenReleaseNotes }: { updaexport function UpdateInfoBar({ updater, onOpen, onDismiss }: { updater: AppUpdater; onOpen: () => void; onDismiss?: () => void }) {const state = useSyncExternalStore(updater.subscribe, updater.getSnapshot);if (state.stage === "available") {- return <InfoBar severity="informational" title="Update available" message={`Slopus ${state.version} is ready to install.`}- action={<button type="button" className="secondary-button" onClick={onOpen}>View update</button>} onClose={onDismiss} />;+ const portable = state.mode === "portable";+ return <InfoBar severity="informational" title="Update available" message={portable ? `Slopus ${state.version} is available to download.` : `Slopus ${state.version} is ready to install.`}+ action={<button type="button" className="secondary-button" onClick={portable ? () => void updater.openReleases() : onOpen}>{portable ? "Open releases" : "View update"}</button>} onClose={onDismiss} />;}if (state.stage === "downloading" || state.stage === "installing") {return <InfoBar severity="informational" title={state.stage === "downloading" ? "Downloading update" : "Installing update"}diff --git a/src/lib/updater.test.ts b/src/lib/updater.test.tsindex eb7c39f..b8aa80b 100644--- a/src/lib/updater.test.ts+++ b/src/lib/updater.test.ts@@ -2,13 +2,13 @@ import { describe, expect, it, vi } from "vitest";import type { DownloadEvent } from "@tauri-apps/plugin-updater";import { AppUpdater } from "./updater";-function setup(enabled = true) {+function setup(mode: "disabled" | "installed" | "portable" = "installed") {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 () => {}) };+ const dependencies = { mode: vi.fn(async () => mode), openReleases: vi.fn(async () => {}), check: vi.fn(async () => update as typeof update | null), relaunch: vi.fn(async () => {}) };return { updater: new AppUpdater(dependencies), update, dependencies };}@@ -22,14 +22,41 @@ describe("app updates", () => {expect(dependencies.relaunch).not.toHaveBeenCalled();});- it("does not check in a browser, debug build or portable distribution", async () => {- const { updater, dependencies } = setup(false);+ it("does not check in a browser or debug build", async () => {+ const { updater, dependencies } = setup("disabled");await updater.start();await updater.check();expect(dependencies.check).not.toHaveBeenCalled();expect(updater.getSnapshot().stage).toBe("disabled");});+ it("checks portable copies and opens releases without downloading, installing or interrupting work", async () => {+ const { updater, update, dependencies } = setup("portable");+ await updater.start();+ expect(dependencies.check).toHaveBeenCalledOnce();+ expect(updater.getSnapshot()).toMatchObject({ stage: "available", mode: "portable", version: "0.2.0" });+ const guard = vi.fn(() => "A project is open.");+ await updater.install(guard);+ expect(dependencies.openReleases).toHaveBeenCalledOnce();+ expect(guard).not.toHaveBeenCalled();+ expect(update.download).not.toHaveBeenCalled();+ expect(update.install).not.toHaveBeenCalled();+ expect(dependencies.relaunch).not.toHaveBeenCalled();+ expect(updater.getSnapshot()).toMatchObject({ stage: "available", error: null });+ });++ it("allows retrying a failed browser launch for a portable update", async () => {+ const { updater, update, dependencies } = setup("portable");+ await updater.start();+ dependencies.openReleases.mockRejectedValueOnce(new Error("Browser unavailable"));+ await updater.install(() => null);+ expect(updater.getSnapshot()).toMatchObject({ stage: "available", error: "Browser unavailable" });+ await updater.install(() => null);+ expect(dependencies.openReleases).toHaveBeenCalledTimes(2);+ expect(updater.getSnapshot().error).toBeNull();+ expect(update.download).not.toHaveBeenCalled();+ });+it("reports no update and releases old native resources when checking again", async () => {const { updater, update, dependencies } = setup();await updater.start();diff --git a/src/lib/updater.ts b/src/lib/updater.tsindex 1fbf1df..3667be4 100644--- a/src/lib/updater.ts+++ b/src/lib/updater.ts@@ -4,8 +4,10 @@ import { check, type Update } from "@tauri-apps/plugin-updater";import { isTauri } from "./persistence";type Stage = "disabled" | "idle" | "checking" | "current" | "available" | "downloading" | "installing" | "restart";+type UpdateMode = "disabled" | "installed" | "portable";interface UpdaterState {stage: Stage;+ mode: UpdateMode;version: string | null;notes: string;downloaded: number;@@ -16,13 +18,15 @@ interface UpdaterState {}type UpdateHandle = Pick<Update, "version" | "body" | "download" | "install" | "close">;interface UpdaterDependencies {- enabled: () => Promise<boolean>;+ mode: () => Promise<UpdateMode>;+ openReleases: () => Promise<void>;check: () => Promise<UpdateHandle | null>;relaunch: () => Promise<void>;now?: () => number;}const native: UpdaterDependencies = {- enabled: async () => isTauri() && await invoke<boolean>("app_updater_enabled"),+ mode: async () => isTauri() ? invoke<UpdateMode>("app_updater_mode") : "disabled",+ openReleases: () => invoke<void>("open_app_releases"),check: () => check({ timeout: 15_000 }),relaunch,};@@ -30,7 +34,7 @@ const describe = (reason: unknown) => reason instanceof Error ? reason.message :/** 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, lastChecked: null };+ private state: UpdaterState = { stage: "disabled", mode: "disabled", version: null, notes: "", downloaded: 0, total: undefined, error: null, lastChecked: null };private listeners = new Set<() => void>();private update: UpdateHandle | null = null;private started = false;@@ -47,8 +51,9 @@ export class AppUpdater {if (this.started) return;this.started = true;try {- if (!await this.dependencies.enabled()) return;- this.publish({ stage: "idle" });+ const mode = await this.dependencies.mode();+ if (mode === "disabled") return;+ this.publish({ stage: "idle", mode });await this.check();} catch (reason) {this.publish({ error: describe(reason) });@@ -70,6 +75,10 @@ export class AppUpdater {};install = async (blockReason: () => string | null) => {if (this.busy || !this.update || this.state.stage !== "available") return;+ if (this.state.mode === "portable") {+ await this.openReleases();+ return;+ }const blocked = blockReason();if (blocked) { this.publish({ error: blocked }); return; }this.busy = true;@@ -92,6 +101,14 @@ export class AppUpdater {this.publish({ stage: installed ? "restart" : "available", error: describe(reason) });} finally { this.busy = false; }};+ openReleases = async () => {+ if (this.busy) return;+ this.busy = true;+ this.publish({ error: null });+ try { await this.dependencies.openReleases(); }+ catch (reason) { this.publish({ error: describe(reason) }); }+ finally { this.busy = false; }+ };restart = async (blockReason: () => string | null) => {if (this.busy || this.state.stage !== "restart") return;const blocked = blockReason();