AI media harness for planning, generating, and editing locally
TypeScript
Move user data and reference icons into Slopus
Bitti816d41fe0ea0
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex 46ee836..2a30a77 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -14,6 +14,8 @@ and editing media locally. This release focuses on video workflows.- Timeline editing, preview, and MP4 export using WebCodecs and WebGPU.- Editable project resolution, aspect ratio, and target length.- Signed application updates and a Work Queue that continues across projects.+- A `Slopus` user data folder with separate `logs` and `reference-icons` folders;+ existing settings and icons migrate at startup.## Getting starteddiff --git a/docs/reference-icons.md b/docs/reference-icons.mdindex 3eff922..c87c7f6 100644--- a/docs/reference-icons.md+++ b/docs/reference-icons.md@@ -24,7 +24,12 @@ can also cancel the batch. An engine or storage failure stops the remainingcatalog so the same failure is not repeated for every reference.Built-in icons are shared across projects. They are saved as 256×256 JPEGs in-`reference-icons/` inside the same directory as `slopus.log`, using stable preset+`%LOCALAPPDATA%/Slopus/reference-icons/`, beside the `logs/` directory, using stable presetIDs as filenames. They load as their cards come into view and are never sent tothe video engine as reference-image attachments. Existing project-specificicons remain in their project folders.++At startup, Slopus migrates the old `com.slopus.desktop` data folder, including+its WebView settings, to `Slopus`. Icons previously inside `logs/reference-icons`+move to the root `reference-icons` folder. Existing destination files are kept;+conflicting legacy files remain available in the old location.diff --git a/src-tauri/src/app_paths.rs b/src-tauri/src/app_paths.rsnew file mode 100644index 0000000..bac37f9--- /dev/null+++ b/src-tauri/src/app_paths.rs@@ -0,0 +1,88 @@+use std::{fs, io, path::{Path, PathBuf}};+use tauri::{AppHandle, Manager};++/// Keep the installed app identity stable while using a readable data directory.+pub fn data_directory(app: &AppHandle) -> PathBuf {+ app.path().local_data_dir().unwrap_or_else(|_| std::env::temp_dir()).join("Slopus")+}++/// Runs before WebView2 opens its profile or diagnostics opens the current log.+pub fn prepare(app: &AppHandle) -> io::Result<PathBuf> {+ let destination = data_directory(app);+ let legacy = destination.parent().unwrap().join("com.slopus.desktop");+ migrate(&legacy, &destination)?;+ Ok(destination)+}++fn move_missing(source: &Path, destination: &Path) -> io::Result<()> {+ if !source.is_dir() { return Ok(()); }+ fs::create_dir_all(destination)?;+ for entry in fs::read_dir(source)? {+ let entry = entry?;+ let target = destination.join(entry.file_name());+ // Never combine WebView database directories or replace newer files.+ if !target.exists() { fs::rename(entry.path(), target)?; }+ }+ if fs::read_dir(source)?.next().is_none() { fs::remove_dir(source)?; }+ Ok(())+}++fn migrate(legacy: &Path, destination: &Path) -> io::Result<()> {+ if legacy.is_dir() && !destination.exists() {+ fs::rename(legacy, destination)?;+ }+ fs::create_dir_all(destination)?;+ let icons = destination.join("reference-icons");+ move_missing(&destination.join("logs/reference-icons"), &icons)?;+ move_missing(&legacy.join("reference-icons"), &icons)?;+ move_missing(&legacy.join("logs/reference-icons"), &icons)?;+ move_missing(&legacy.join("logs"), &destination.join("logs"))?;+ move_missing(legacy, destination)?;+ Ok(())+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn moves_the_profile_logs_and_icons_before_startup() {+ let temp = tempfile::tempdir().unwrap();+ let legacy = temp.path().join("com.slopus.desktop");+ let destination = temp.path().join("Slopus");+ fs::create_dir_all(legacy.join("EBWebView")).unwrap();+ fs::create_dir_all(legacy.join("logs/reference-icons")).unwrap();+ fs::write(legacy.join("EBWebView/preferences"), b"settings").unwrap();+ fs::write(legacy.join("logs/slopus.log"), b"previous session").unwrap();+ fs::write(legacy.join("logs/reference-icons/alice.jpg"), b"finished icon").unwrap();+ migrate(&legacy, &destination).unwrap();+ assert!(!legacy.exists());+ assert!(!destination.join("logs/reference-icons").exists());+ assert_eq!(fs::read(destination.join("EBWebView/preferences")).unwrap(), b"settings");+ assert_eq!(fs::read(destination.join("logs/slopus.log")).unwrap(), b"previous session");+ assert_eq!(fs::read(destination.join("reference-icons/alice.jpg")).unwrap(), b"finished icon");+ migrate(&legacy, &destination).unwrap();+ }++ #[test]+ fn preserves_existing_data_and_keeps_conflicting_legacy_files() {+ let temp = tempfile::tempdir().unwrap();+ let legacy = temp.path().join("com.slopus.desktop");+ let destination = temp.path().join("Slopus");+ for root in [&legacy, &destination] {+ fs::create_dir_all(root.join("EBWebView")).unwrap();+ fs::create_dir_all(root.join("reference-icons")).unwrap();+ }+ fs::write(legacy.join("EBWebView/preferences"), b"old").unwrap();+ fs::write(destination.join("EBWebView/preferences"), b"new").unwrap();+ fs::write(legacy.join("reference-icons/alice.jpg"), b"old icon").unwrap();+ fs::write(destination.join("reference-icons/alice.jpg"), b"new icon").unwrap();+ fs::write(legacy.join("reference-icons/bob.jpg"), b"other icon").unwrap();+ migrate(&legacy, &destination).unwrap();+ assert_eq!(fs::read(destination.join("EBWebView/preferences")).unwrap(), b"new");+ assert_eq!(fs::read(legacy.join("EBWebView/preferences")).unwrap(), b"old");+ assert_eq!(fs::read(destination.join("reference-icons/alice.jpg")).unwrap(), b"new icon");+ assert_eq!(fs::read(legacy.join("reference-icons/alice.jpg")).unwrap(), b"old icon");+ assert!(destination.join("reference-icons/bob.jpg").is_file());+ }+}diff --git a/src-tauri/src/diagnostics.rs b/src-tauri/src/diagnostics.rsindex 33c4e92..565055a 100644--- a/src-tauri/src/diagnostics.rs+++ b/src-tauri/src/diagnostics.rs@@ -16,7 +16,7 @@ use std::{sync::{Mutex, Once, OnceLock},time::{SystemTime, UNIX_EPOCH},};-use tauri::{AppHandle, Manager};+use tauri::AppHandle;const ACTIVE_FILE: &str = "slopus.log";const PREVIOUS_FILE: &str = "slopus-prev.log";@@ -286,10 +286,7 @@ fn redact(value: Value, depth: usize) -> Value {}pub fn directory(app: &AppHandle) -> PathBuf {- app- .path()- .app_log_dir()- .unwrap_or_else(|_| std::env::temp_dir().join("slopus").join("logs"))+ crate::app_paths::data_directory(app).join("logs")}pub fn initialize(app: &AppHandle) -> Result<DiagnosticLogInfo, String> {diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex a210fde..b1c1cf7 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -10,6 +10,7 @@ use tauri_plugin_dialog::DialogExt;mod agent;mod agent_commands;+mod app_paths;mod cuda_support;mod diagnostics;mod export;@@ -2777,17 +2778,17 @@ fn reference_icon_pixels(job_id: &str) -> Result<Vec<u8>, String> {#[tauri::command]fn list_builtin_reference_icons(app: AppHandle) -> Result<Vec<String>, String> {- reference_icons::list_builtin(&diagnostics::directory(&app))+ reference_icons::list_builtin(&app_paths::data_directory(&app))}#[tauri::command]fn read_builtin_reference_icon(app: AppHandle, preset_id: String) -> Result<tauri::ipc::Response, String> {- reference_icons::read_builtin(&diagnostics::directory(&app), &preset_id).map(tauri::ipc::Response::new)+ reference_icons::read_builtin(&app_paths::data_directory(&app), &preset_id).map(tauri::ipc::Response::new)}#[tauri::command]fn save_builtin_reference_icon(app: AppHandle, preset_id: String, job_id: String) -> Result<(), String> {- reference_icons::save_builtin(&diagnostics::directory(&app), &preset_id, &reference_icon_pixels(&job_id)?)+ reference_icons::save_builtin(&app_paths::data_directory(&app), &preset_id, &reference_icon_pixels(&job_id)?)}fn write_reference_icon_frame(folder_path: &str, job_id: &str, rgba: &[u8]) -> Result<String, String> {@@ -2950,6 +2951,11 @@ pub fn run() {tauri::Builder::default().setup(|app| {use tauri::Manager as _;+ let data_directory = app_paths::prepare(app.handle())?;+ let window_config = app.config().app.windows.first().ok_or_else(|| io::Error::other("Missing main window configuration"))?;+ tauri::WebviewWindowBuilder::from_config(app, window_config)?+ .data_directory(data_directory)+ .build()?;match diagnostics::initialize(app.handle()) {Ok(info) => diagnostics::info("app",diff --git a/src-tauri/src/reference_icons.rs b/src-tauri/src/reference_icons.rsindex 3754d5d..4f39bce 100644--- a/src-tauri/src/reference_icons.rs+++ b/src-tauri/src/reference_icons.rs@@ -5,37 +5,37 @@ pub const ICON_SIZE: u16 = 256;pub const STEPS: i32 = 20;const JPEG_QUALITY: u8 = 95;-fn builtin_directory(log_directory: &Path) -> Result<PathBuf, String> {- fs::create_dir_all(log_directory).map_err(|error| error.to_string())?;- let root = log_directory.canonicalize().map_err(|error| error.to_string())?;+fn builtin_directory(data_directory: &Path) -> Result<PathBuf, String> {+ fs::create_dir_all(data_directory).map_err(|error| error.to_string())?;+ let root = data_directory.canonicalize().map_err(|error| error.to_string())?;let directory = root.join("reference-icons");fs::create_dir_all(&directory).map_err(|error| error.to_string())?;let directory = directory.canonicalize().map_err(|error| error.to_string())?;- if !directory.starts_with(&root) { return Err("Built-in icons must stay inside the log directory.".into()); }+ if !directory.starts_with(&root) { return Err("Built-in icons must stay inside the Slopus data directory.".into()); }Ok(directory)}-fn builtin_path(log_directory: &Path, id: &str) -> Result<PathBuf, String> {+fn builtin_path(data_directory: &Path, id: &str) -> Result<PathBuf, String> {if id.is_empty() || id.len() > 160 || !id.bytes().all(|byte| byte.is_ascii_alphanumeric() || byte == b'-' || byte == b'_') {return Err("Invalid built-in reference icon ID.".into());}- Ok(builtin_directory(log_directory)?.join(format!("{id}.jpg")))+ Ok(builtin_directory(data_directory)?.join(format!("{id}.jpg")))}-pub fn save_builtin(log_directory: &Path, id: &str, rgba: &[u8]) -> Result<(), String> {- let path = builtin_path(log_directory, id)?;+pub fn save_builtin(data_directory: &Path, id: &str, rgba: &[u8]) -> Result<(), String> {+ let path = builtin_path(data_directory, id)?;crate::export::write_atomically(&path, &encode_jpeg(rgba)?)}-pub fn read_builtin(log_directory: &Path, id: &str) -> Result<Vec<u8>, String> {- let path = builtin_path(log_directory, id)?;+pub fn read_builtin(data_directory: &Path, id: &str) -> Result<Vec<u8>, String> {+ let path = builtin_path(data_directory, id)?;let resolved = path.canonicalize().map_err(|error| error.to_string())?;if !resolved.starts_with(path.parent().unwrap()) { return Err("Built-in icon points outside its directory.".into()); }fs::read(resolved).map_err(|error| error.to_string())}-pub fn list_builtin(log_directory: &Path) -> Result<Vec<String>, String> {- let directory = builtin_directory(log_directory)?;+pub fn list_builtin(data_directory: &Path) -> Result<Vec<String>, String> {+ let directory = builtin_directory(data_directory)?;let mut ids = Vec::new();for entry in fs::read_dir(&directory).map_err(|error| error.to_string())? {let entry = entry.map_err(|error| error.to_string())?;@@ -43,7 +43,7 @@ pub fn list_builtin(log_directory: &Path) -> Result<Vec<String>, String> {let path = entry.path();if path.extension().and_then(|value| value.to_str()) != Some("jpg") { continue; }if let Some(id) = path.file_stem().and_then(|value| value.to_str()) {- if builtin_path(log_directory, id).is_ok() { ids.push(id.to_string()); }+ if builtin_path(data_directory, id).is_ok() { ids.push(id.to_string()); }}}ids.sort();@@ -92,17 +92,17 @@ mod tests {use super::*;#[test]- fn builtins_are_shared_in_a_subfolder_of_the_log_directory() {+ fn builtins_are_shared_in_a_subfolder_of_the_data_directory() {let root = tempfile::tempdir().unwrap();- let logs = root.path().join("logs");+ let data = root.path().join("Slopus");let rgba = vec![127; RENDER_SIZE as usize * RENDER_SIZE as usize * 4];- save_builtin(&logs, "character-alice", &rgba).unwrap();- assert!(logs.join("reference-icons/character-alice.jpg").is_file());- assert_eq!(list_builtin(&logs).unwrap(), ["character-alice"]);- assert!(read_builtin(&logs, "character-alice").unwrap().starts_with(&[0xff, 0xd8]));- assert!(save_builtin(&logs, "../escape", &rgba).is_err());- assert!(read_builtin(&logs, "../escape").is_err());- assert!(save_builtin(&logs, "invalid", &[0; 4]).is_err());+ save_builtin(&data, "character-alice", &rgba).unwrap();+ assert!(data.join("reference-icons/character-alice.jpg").is_file());+ assert_eq!(list_builtin(&data).unwrap(), ["character-alice"]);+ assert!(read_builtin(&data, "character-alice").unwrap().starts_with(&[0xff, 0xd8]));+ assert!(save_builtin(&data, "../escape", &rgba).is_err());+ assert!(read_builtin(&data, "../escape").is_err());+ assert!(save_builtin(&data, "invalid", &[0; 4]).is_err());}#[test]diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.jsonindex 999a28f..939715f 100644--- a/src-tauri/tauri.conf.json+++ b/src-tauri/tauri.conf.json@@ -12,6 +12,7 @@"app": {"windows": [{+ "create": false,"title": "Slopus - 0.1.0","width": 1440,"height": 920,diff --git a/src/components/SettingsView.test.tsx b/src/components/SettingsView.test.tsxindex f6f0d13..a986572 100644--- a/src/components/SettingsView.test.tsx+++ b/src/components/SettingsView.test.tsx@@ -254,7 +254,7 @@ describe("the settings screen", () => {it("offers only a button to reveal the log without fetching log details", async () => {Object.defineProperty(window, "__TAURI_INTERNALS__", { configurable: true, value: {} });const info = {- path: "C:\\Users\\Editor\\AppData\\Local\\com.slopus.desktop\\logs\\slopus.log",+ path: "C:\\Users\\Editor\\AppData\\Local\\Slopus\\logs\\slopus.log",previousPath: null,sessionId: "42-1",maxFileBytes: 5_242_880,