AI media harness for planning, generating, and editing locally
TypeScript
Detect installed copies for automatic updates
Bittid966c7cf4729
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex 0d2ce1e..c127d21 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -41,7 +41,7 @@ This alpha update adds LAN generation workers, Linux support, expanded color gra- Removing a reference from a scene's last prompt citation now removes it from generation inputs and “Used by.” References selected as frame or motion inputs remain active.- Copy and paste effect settings between matching effects from their **…** menus, including bypass state and LUT data.- Add voice reference chips directly in a shot's Speech field. Voice guidance stays separate from the words spoken.-- Portable builds show available updates and open GitHub releases for manual updating instead of running an installer.+- Loose Windows executables are automatically detected as portable without a marker file. Portable builds show available updates and open GitHub releases for manual updating; NSIS and MSI installations are recognized by their registered installation folder and can update in place.- Agent chat uses message bubbles with formatted replies and avoids repeating completed responses.- New empty images created while browsing child images stay in the same image family.- Renamed the Look effect to Opacity and removed its Temperature control. Temperature adjustment is available in Basic Corrections.diff --git a/docs/updater.md b/docs/updater.mdindex fcb018c..9ec2754 100644--- a/docs/updater.md+++ b/docs/updater.md@@ -6,19 +6,22 @@ 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 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+Browser previews and debug builds do not check for updates. On Windows, release+builds enable installer updates only when a Slopus NSIS or MSI uninstall entry+registers the running executable's exact installation folder. Detection checks+both user and machine registrations and both registry views, including custom+installation folders and existing installations. Unregistered copies of+`Slopus.exe` and `slopfab.dll` are portable automatically; no marker file is needed.+They check on startup and in Settings, showavailable versions and release notes, and offer **Open releases** to openhttps://github.com/bitti-ai/slopus/releases in the default browser. They neverdownload or run an installer, and opening the page does not require closing aproject 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.+replace `Slopus.exe` and `slopfab.dll` together in the existing folder. Settings,+projects and downloaded models are preserved. A portable copy remains portable+even if another copy of Slopus is installed elsewhere on the same computer.## Pre-release testsdiff --git a/package.cmd b/package.cmdindex a8e21f5..11f75e5 100644--- a/package.cmd+++ b/package.cmd@@ -114,9 +114,7 @@ echo Folder: %OUTPUT_STEM%-portable\echo.echo [5/5] Creating the portable archive...-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/releases-if errorlevel 1 goto :fail+rem Loose binaries are portable automatically; no marker file is needed.powershell.exe -NoProfile -NonInteractive -Command "$ErrorActionPreference='Stop'; Compress-Archive -Path (Join-Path $env:OUTPUT_DIR '*') -DestinationPath $env:OUTPUT_ZIP -CompressionLevel Optimal -Force" || goto :failcall :package_worker || goto :failcall :package_linux_worker || goto :faildiff --git a/release.cmd b/release.cmdindex dd791c4..7253e49 100644--- a/release.cmd+++ b/release.cmd@@ -171,9 +171,7 @@ echo Folder: %OUTPUT_STEM%-portable\echo.echo [6/6] Creating the portable archive...-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/releases-if errorlevel 1 goto :fail+rem Loose binaries are portable automatically; no marker file is needed.powershell.exe -NoProfile -NonInteractive -Command "$ErrorActionPreference='Stop'; Compress-Archive -Path (Join-Path $env:OUTPUT_DIR '*') -DestinationPath $env:OUTPUT_ZIP -CompressionLevel Optimal -Force" || goto :failcall :package_worker || goto :failcall :package_linux_worker || goto :faildiff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex b151555..3c5a630 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -75,7 +75,7 @@ windows = { version = "0.61", features = ["Wdk_System_SystemServices","Win32_System_SystemInformation",] }-windows-sys = { version = "0.59", features = ["Win32_Foundation", "Win32_Storage_FileSystem", "Win32_UI_Shell"] }+windows-sys = { version = "0.59", features = ["Win32_Foundation", "Win32_Storage_FileSystem", "Win32_System_Registry", "Win32_UI_Shell"] }[target.'cfg(target_os = "linux")'.dependencies]# Must stay on wry's major: with_webview hands back its WebKitGTK view. Turnsdiff --git a/src-tauri/src/app.rs b/src-tauri/src/app.rsindex 9c29323..ff69aa0 100644--- a/src-tauri/src/app.rs+++ b/src-tauri/src/app.rs@@ -7,15 +7,7 @@ use std::io;/// Portable copies check for updates but open the release page for manual updates.#[tauri::command]fn app_updater_mode() -> Result<&'static str, String> {- if cfg!(debug_assertions) { return Ok("disabled"); }- /* On Linux the updater replaces only an AppImage (whose runtime sets- APPIMAGE); .deb and .rpm installs belong to the package manager. */- if cfg!(target_os = "linux") {- return Ok(if std::env::var_os("APPIMAGE").is_some() { "installed" } else { "portable" });- }- 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" })+ crate::updater_mode::detect()}#[tauri::command]diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 6439998..8cc0f41 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -14,6 +14,7 @@ mod media;mod native_shell;mod project;mod slop;+mod updater_mode;mod weights;mod window;mod worker;diff --git a/src-tauri/src/updater_mode.rs b/src-tauri/src/updater_mode.rsnew file mode 100644index 0000000..87e1d98--- /dev/null+++ b/src-tauri/src/updater_mode.rs@@ -0,0 +1,265 @@+//! A loose executable is portable unless an installer owns its exact location.+pub(crate) fn detect() -> Result<&'static str, String> {+ if cfg!(debug_assertions) {+ return Ok("disabled");+ }+ // Tauri can replace an AppImage. Other Linux packages update through their+ // package manager or the releases page, not the AppImage updater payload.+ #[cfg(target_os = "linux")]+ if std::env::var_os("APPIMAGE").is_some() {+ return Ok("installed");+ }+ #[cfg(windows)]+ if windows::is_registered(&std::env::current_exe().map_err(|error| error.to_string())?) {+ return Ok("installed");+ }+ Ok("portable")+}++#[cfg(any(windows, test))]+fn matches_install(+ executable: &std::path::Path,+ name: &str,+ publisher: &str,+ location: &str,+) -> bool {+ if !name.eq_ignore_ascii_case("Slopus")+ || !publisher.eq_ignore_ascii_case("slopus")+ || !executable+ .file_name()+ .and_then(|name| name.to_str())+ .is_some_and(|name| name.eq_ignore_ascii_case("slopus.exe"))+ {+ return false;+ }+ // NSIS quotes InstallLocation; WiX writes the unquoted directory with a+ // trailing separator. Do not accept relative, missing or stale locations.+ let location = location.trim();+ let location = location+ .strip_prefix('"')+ .and_then(|value| value.strip_suffix('"'))+ .unwrap_or(location);+ let directory = std::path::Path::new(location);+ if !directory.is_absolute() {+ return false;+ }+ let (Ok(executable), Ok(directory)) = (executable.canonicalize(), directory.canonicalize())+ else {+ return false;+ };+ executable.parent() == Some(directory.as_path())+}++#[cfg(windows)]+mod windows {+ use std::{path::Path, ptr};+ use windows_sys::Win32::{Foundation::ERROR_SUCCESS, System::Registry::*};++ const UNINSTALL: &str = r"Software\Microsoft\Windows\CurrentVersion\Uninstall";++ struct Key(HKEY);+ impl Drop for Key {+ fn drop(&mut self) {+ unsafe {+ RegCloseKey(self.0);+ }+ }+ }++ fn wide(value: &str) -> Vec<u16> {+ value.encode_utf16().chain(Some(0)).collect()+ }++ fn string(key: HKEY, subkey: &[u16], name: &str) -> Option<String> {+ let name = wide(name);+ let mut bytes = 0;+ // Read only REG_SZ, as written by both shipped Windows installers.+ if unsafe {+ RegGetValueW(+ key,+ subkey.as_ptr(),+ name.as_ptr(),+ RRF_RT_REG_SZ,+ ptr::null_mut(),+ ptr::null_mut(),+ &mut bytes,+ )+ } != ERROR_SUCCESS+ || bytes == 0+ || bytes > 65_536+ || bytes % 2 != 0+ {+ return None;+ }+ let mut buffer = vec![0u16; bytes as usize / 2];+ if unsafe {+ RegGetValueW(+ key,+ subkey.as_ptr(),+ name.as_ptr(),+ RRF_RT_REG_SZ,+ ptr::null_mut(),+ buffer.as_mut_ptr().cast(),+ &mut bytes,+ )+ } != ERROR_SUCCESS+ {+ return None;+ }+ let end = buffer+ .iter()+ .position(|&unit| unit == 0)+ .unwrap_or(buffer.len());+ String::from_utf16(&buffer[..end]).ok()+ }++ pub(super) fn is_registered(executable: &Path) -> bool {+ let uninstall = wide(UNINSTALL);+ // NSIS uses a named key; MSI uses a product GUID. Enumerating the+ // uninstall records supports both, including already-installed releases.+ // Check user/machine scopes and both registry views for custom installs.+ for root in [HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE] {+ for view in [KEY_WOW64_64KEY, KEY_WOW64_32KEY] {+ let mut raw = ptr::null_mut();+ if unsafe { RegOpenKeyExW(root, uninstall.as_ptr(), 0, KEY_READ | view, &mut raw) }+ != ERROR_SUCCESS+ {+ continue;+ }+ let key = Key(raw);+ let mut index = 0;+ loop {+ // Registry key names are at most 255 UTF-16 characters.+ let mut subkey = [0u16; 256];+ let mut length = subkey.len() as u32;+ if unsafe {+ RegEnumKeyExW(+ key.0,+ index,+ subkey.as_mut_ptr(),+ &mut length,+ ptr::null(),+ ptr::null_mut(),+ ptr::null_mut(),+ ptr::null_mut(),+ )+ } != ERROR_SUCCESS+ {+ break;+ }+ index += 1;+ let Some(name) = string(key.0, &subkey, "DisplayName") else {+ continue;+ };+ if !name.eq_ignore_ascii_case("Slopus") {+ continue;+ }+ let Some(publisher) = string(key.0, &subkey, "Publisher") else {+ continue;+ };+ let Some(location) = string(key.0, &subkey, "InstallLocation") else {+ continue;+ };+ if super::matches_install(executable, &name, &publisher, &location) {+ return true;+ }+ }+ }+ }+ false+ }+}++#[cfg(test)]+mod tests {+ use super::*;+ use std::fs;++ #[test]+ fn recognizes_nsis_and_msi_locations_including_custom_install_folders() {+ let installed = tempfile::tempdir().unwrap();+ let executable = installed.path().join("Slopus.exe");+ fs::write(&executable, []).unwrap();+ let location = installed.path().to_string_lossy();+ assert!(matches_install(+ &executable,+ "Slopus",+ "slopus",+ &format!("\"{location}\"")+ ));+ assert!(matches_install(+ &executable,+ "SLOPUS",+ "Slopus",+ &format!("{location}/")+ ));+ }++ #[test]+ fn a_loose_copy_is_portable_even_when_slopus_is_installed_elsewhere() {+ let installed = tempfile::tempdir().unwrap();+ let portable = tempfile::tempdir().unwrap();+ let executable = portable.path().join("slopus.exe");+ fs::write(&executable, []).unwrap();+ fs::write(portable.path().join("slopfab.dll"), []).unwrap();+ assert!(!matches_install(+ &executable,+ "Slopus",+ "slopus",+ &installed.path().to_string_lossy()+ ));+ // A similarly named directory or a loose copy beneath an installation+ // is not the installed application either.+ let child = installed.path().join("portable");+ fs::create_dir(&child).unwrap();+ fs::copy(&executable, child.join("slopus.exe")).unwrap();+ assert!(!matches_install(+ &child.join("slopus.exe"),+ "Slopus",+ "slopus",+ &installed.path().to_string_lossy()+ ));+ }++ #[test]+ fn unrelated_incomplete_or_stale_registry_entries_do_not_enable_installation() {+ let installed = tempfile::tempdir().unwrap();+ let executable = installed.path().join("slopus.exe");+ fs::write(&executable, []).unwrap();+ let location = installed.path().to_string_lossy();+ assert!(!matches_install(+ &executable,+ "Another app",+ "slopus",+ &location+ ));+ assert!(!matches_install(+ &executable,+ "Slopus",+ "Other publisher",+ &location+ ));+ for location in [+ "",+ ".",+ "relative/install",+ "\"unterminated",+ "Z:/missing-slopus-install",+ ] {+ assert!(!matches_install(&executable, "Slopus", "slopus", location));+ }+ assert!(!matches_install(+ &installed.path().join("missing.exe"),+ "Slopus",+ "slopus",+ &location+ ));+ }++ #[test]+ fn debug_builds_disable_the_updater() {+ if cfg!(debug_assertions) {+ assert_eq!(detect().unwrap(), "disabled");+ }+ }+}