diff --git a/packages/stablestudio-ui/src-tauri/Cargo.lock b/packages/stablestudio-ui/src-tauri/Cargo.lock index b94b6c0..6af09eb 100644 --- a/packages/stablestudio-ui/src-tauri/Cargo.lock +++ b/packages/stablestudio-ui/src-tauri/Cargo.lock @@ -703,7 +703,7 @@ checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -753,7 +753,7 @@ dependencies = [ "cfg-if", "libc", "redox_syscall 0.2.16", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1494,7 +1494,7 @@ checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ "hermit-abi", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1741,7 +1741,7 @@ checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1960,6 +1960,17 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "os_info" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "006e42d5b888366f1880eda20371fedde764ed2213dc8496f49622fa0c99cd5e" +dependencies = [ + "log", + "serde", + "winapi", +] + [[package]] name = "os_pipe" version = "1.1.4" @@ -1967,7 +1978,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ae859aa07428ca9a929b936690f8b12dc5f11dd8c6992a18ca93919f28bc177" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2021,7 +2032,7 @@ dependencies = [ "libc", "redox_syscall 0.3.5", "smallvec", - "windows-targets", + "windows-targets 0.48.1", ] [[package]] @@ -2520,7 +2531,7 @@ dependencies = [ "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2556,7 +2567,7 @@ version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2927,6 +2938,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sys-locale" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8a11bd9c338fdba09f7881ab41551932ad42e405f61d01e8406baea71c07aee" +dependencies = [ + "js-sys", + "libc", + "wasm-bindgen", + "web-sys", + "windows-sys 0.45.0", +] + [[package]] name = "system-deps" version = "5.0.0" @@ -3049,6 +3073,7 @@ dependencies = [ "ignore", "objc", "once_cell", + "os_info", "os_pipe", "percent-encoding", "rand 0.8.5", @@ -3060,6 +3085,7 @@ dependencies = [ "serialize-to-javascript", "shared_child", "state", + "sys-locale", "tar", "tauri-macros", "tauri-runtime", @@ -3239,7 +3265,7 @@ dependencies = [ "fastrand", "redox_syscall 0.3.5", "rustix", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -3368,7 +3394,7 @@ dependencies = [ "num_cpus", "pin-project-lite", "socket2", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -3893,7 +3919,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets", + "windows-targets 0.48.1", ] [[package]] @@ -3922,13 +3948,37 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ee5e275231f07c6e240d14f34e1b635bf1faa1c76c57cfd59a5cdb9848e4278" +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.1", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -3937,12 +3987,12 @@ version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ - "windows_aarch64_gnullvm", + "windows_aarch64_gnullvm 0.48.0", "windows_aarch64_msvc 0.48.0", "windows_i686_gnu 0.48.0", "windows_i686_msvc 0.48.0", "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm", + "windows_x86_64_gnullvm 0.48.0", "windows_x86_64_msvc 0.48.0", ] @@ -3952,6 +4002,12 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f838de2fe15fe6bac988e74b798f26499a8b21a9d97edec321e79b28d1d7f597" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.0" @@ -3964,6 +4020,12 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec7711666096bd4096ffa835238905bb33fb87267910e154b18b44eaabb340f2" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + [[package]] name = "windows_aarch64_msvc" version = "0.48.0" @@ -3976,6 +4038,12 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "763fc57100a5f7042e3057e7e8d9bdd7860d330070251a73d003563a3bb49e1b" +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + [[package]] name = "windows_i686_gnu" version = "0.48.0" @@ -3988,6 +4056,12 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7bc7cbfe58828921e10a9f446fcaaf649204dcfe6c1ddd712c5eebae6bda1106" +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + [[package]] name = "windows_i686_msvc" version = "0.48.0" @@ -4000,12 +4074,24 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6868c165637d653ae1e8dc4d82c25d4f97dd6605eaa8d784b5c6e0ab2a252b65" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" @@ -4018,6 +4104,12 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e4d40883ae9cae962787ca76ba76390ffa29214667a111db9e0a1ad8377e809" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + [[package]] name = "windows_x86_64_msvc" version = "0.48.0" diff --git a/packages/stablestudio-ui/src-tauri/Cargo.toml b/packages/stablestudio-ui/src-tauri/Cargo.toml index ed2dba7..d7926b6 100644 --- a/packages/stablestudio-ui/src-tauri/Cargo.toml +++ b/packages/stablestudio-ui/src-tauri/Cargo.toml @@ -17,7 +17,7 @@ tauri-build = { version = "1.4.0", features = [] } [dependencies] serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = { version = "1.4.1", features = [ "fs-all", "path-all", "process-command-api", "devtools"] } +tauri = { version = "1.4.1", features = [ "os-all", "fs-all", "path-all", "process-command-api", "devtools"] } tauri-plugin-upload = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } zip = "0.6.6" zip-extensions = "0.6.1" diff --git a/packages/stablestudio-ui/src-tauri/src/main.rs b/packages/stablestudio-ui/src-tauri/src/main.rs index fc33fc6..15b2553 100644 --- a/packages/stablestudio-ui/src-tauri/src/main.rs +++ b/packages/stablestudio-ui/src-tauri/src/main.rs @@ -15,6 +15,7 @@ use tauri::{RunEvent, Window, WindowBuilder, WindowUrl}; use tauri_plugin_upload; mod server; +mod show_path; static WINDOW: OnceLock = OnceLock::new(); @@ -58,7 +59,11 @@ fn main() { Ok(()) }) .plugin(tauri_plugin_upload::init()) - .invoke_handler(tauri::generate_handler![extract_comfy, launch_comfy]) + .invoke_handler(tauri::generate_handler![ + extract_comfy, + launch_comfy, + show_path::show_in_folder + ]) .build(context) .expect("error while building tauri application") .run(move |_app_handle, event| match event { diff --git a/packages/stablestudio-ui/src-tauri/src/server.rs b/packages/stablestudio-ui/src-tauri/src/server.rs index 5d73626..5c8caf9 100644 --- a/packages/stablestudio-ui/src-tauri/src/server.rs +++ b/packages/stablestudio-ui/src-tauri/src/server.rs @@ -76,7 +76,7 @@ impl Builder { Some("text/html".to_string()), None, ), - ["api" | "prompt" | "object_info" | "view" | "history" | "queue" | "extensions", ..] => ( + ["api" | "prompt" | "object_info" | "view" | "history" | "queue" | "interrupt" | "extensions", ..] => ( None, None, Some( diff --git a/packages/stablestudio-ui/src-tauri/src/show_path.rs b/packages/stablestudio-ui/src-tauri/src/show_path.rs new file mode 100644 index 0000000..9bfd4d2 --- /dev/null +++ b/packages/stablestudio-ui/src-tauri/src/show_path.rs @@ -0,0 +1,52 @@ +#[cfg(target_os = "linux")] +use fork::{daemon, Fork}; +use std::process::Command; +#[cfg(target_os = "linux")] +use std::{fs::metadata, path::PathBuf}; // dep: fork = "0.1" + +#[tauri::command] +pub fn show_in_folder(path: String) { + #[cfg(target_os = "windows")] + { + Command::new("explorer") + .args(["/select,", &path]) // The comma after select is not a typo + .spawn() + .unwrap(); + } + + #[cfg(target_os = "linux")] + { + if path.contains(",") { + // see https://gitlab.freedesktop.org/dbus/dbus/-/issues/76 + let new_path = match metadata(&path).unwrap().is_dir() { + true => path, + false => { + let mut path2 = PathBuf::from(path); + path2.pop(); + path2.into_os_string().into_string().unwrap() + } + }; + Command::new("xdg-open").arg(&new_path).spawn().unwrap(); + } else { + if let Ok(Fork::Child) = daemon(false, false) { + Command::new("dbus-send") + .args([ + "--session", + "--dest=org.freedesktop.FileManager1", + "--type=method_call", + "/org/freedesktop/FileManager1", + "org.freedesktop.FileManager1.ShowItems", + format!("array:string:\"file://{path}\"").as_str(), + "string:\"\"", + ]) + .spawn() + .unwrap(); + } + } + } + + #[cfg(target_os = "macos")] + { + Command::new("open").args(["-R", &path]).spawn().unwrap(); + } +} diff --git a/packages/stablestudio-ui/src-tauri/tauri.conf.json b/packages/stablestudio-ui/src-tauri/tauri.conf.json index c22c6e9..abf64da 100644 --- a/packages/stablestudio-ui/src-tauri/tauri.conf.json +++ b/packages/stablestudio-ui/src-tauri/tauri.conf.json @@ -17,6 +17,9 @@ }, "path": { "all": true + }, + "os": { + "all": true } }, "bundle": { diff --git a/packages/stablestudio-ui/src/Comfy/plugin.ts b/packages/stablestudio-ui/src/Comfy/plugin.ts index 3d583a1..67f73ff 100644 --- a/packages/stablestudio-ui/src/Comfy/plugin.ts +++ b/packages/stablestudio-ui/src/Comfy/plugin.ts @@ -1,61 +1,11 @@ import * as StableStudio from "@stability/stablestudio-plugin"; -export const createPlugin = StableStudio.createPlugin(({ set, get }) => { +export const createPlugin = StableStudio.createPlugin(() => { return { manifest: { - name: "ComfyUI Backend", + name: "ComfyUI", }, - statusStuff: { - indicator: "loading", - text: "Starting", - }, - - // createStableDiffusionImages: async () => { - // const comfy = Comfy.get(); - - // if (!comfy) { - // console.log(document.getElementById("comfyui-window")); - // throw new Error("ComfyUI is not loaded"); - // } - - // await comfy.queuePrompt(1, 1); - - // const p = new Promise((resolve, reject) => { - - // }); - - // const image = await fetch(`${window.location.origin}/DummyImage.png`); - // const blob = await image.blob(); - // const createdAt = new Date(); - - // return { - // id: `${Math.random() * 10000000}`, - // images: [ - // { - // id: `${Math.random() * 10000000}`, - // createdAt, - // blob, - // }, - // { - // id: `${Math.random() * 10000000}`, - // createdAt, - // blob, - // }, - // { - // id: `${Math.random() * 10000000}`, - // createdAt, - // blob, - // }, - // { - // id: `${Math.random() * 10000000}`, - // createdAt, - // blob, - // }, - // ], - // }; - // }, - getStableDiffusionModels: async () => { const resp = await fetch("/object_info/CheckpointLoader", { cache: "no-cache", @@ -96,17 +46,12 @@ export const createPlugin = StableStudio.createPlugin(({ set, get }) => { ); }, - getStatus: () => { - fetch("/comfyui", { cache: "no-cache" }).then((resp) => { - set({ - statusStuff: { - indicator: resp.ok ? "success" : "error", - text: resp.ok ? "Running" : "Not Running", - }, - }); - }); - - return get().statusStuff; + getStatus: async () => { + const resp = await fetch("/comfyui", { cache: "no-cache" }); + return { + indicator: resp.ok ? "success" : "error", + text: resp.ok ? "Running" : "Not Running", + }; }, }; }); diff --git a/packages/stablestudio-ui/src/Settings/index.tsx b/packages/stablestudio-ui/src/Settings/index.tsx index 60d938d..b97738d 100644 --- a/packages/stablestudio-ui/src/Settings/index.tsx +++ b/packages/stablestudio-ui/src/Settings/index.tsx @@ -1,17 +1,20 @@ import { PluginStatus } from "@stability/stablestudio-plugin"; +import { getTauriVersion, getVersion } from "@tauri-apps/api/app"; +import { version as getOsVerison, platform } from "@tauri-apps/api/os"; +import { appDataDir } from "@tauri-apps/api/path"; +import { invoke } from "@tauri-apps/api/tauri"; import { Link } from "react-router-dom"; import { GlobalState } from "~/GlobalState"; import { Plugin } from "~/Plugin"; import { Theme } from "~/Theme"; -import { Install } from "./Install"; import { Manifest } from "./Manifest"; -import { Setting } from "./Setting"; export function Settings() { const [pluginStatus, setPluginStatus] = useState(); - const pluginSetup = Plugin.useSetup(); + const [comfyLocation, setComfyLocation] = useState(); + const [versions, setVersions] = useState([]); const { manifest, settings, setSetting, getStatus } = Plugin.use( ({ manifest, settings, setSetting, getStatus }) => ({ @@ -22,8 +25,6 @@ export function Settings() { }) ); - const { developerMode, setDeveloperMode } = Settings.use(); - useEffect(() => { function fetchStatus() { if (!getStatus) return; @@ -57,6 +58,29 @@ export function Settings() { [settings] ); + useEffect(() => { + async function fetchComfyLocation() { + const path = await appDataDir(); + setComfyLocation(`${path}ComfyUI`); + } + + async function fetchVersion() { + const version = await getVersion(); + const tauriVersion = await getTauriVersion(); + const os = await platform(); + const osVersion = await getOsVerison(); + + setVersions([ + `StableStudio (${version})`, + `Tauri (${tauriVersion})`, + `${os} (${osVersion})`, + ]); + } + + fetchComfyLocation(); + fetchVersion(); + }, []); + return ( <>
@@ -78,24 +102,41 @@ export function Settings() { settings={settings ?? {}} setSetting={setSetting as never} /> - setDeveloperMode(!developerMode)} - settingValue={{ - type: "boolean", - title: "Developer mode", - description: - "Enable experimental features such as installing untrusted plugins", +
+
+ +
+
+ + { + await invoke("show_in_folder", { path: comfyLocation }); + }} + > + + +
+
- required: false, - value: developerMode, - }} - /> - {developerMode && ( - url && pluginSetup.loadFromURL(url)} - /> - )} +
+ {versions.map((version, i) => ( + <> + {i !== 0 && ( +
+ · +
+ )} +
{version}
+ + ))} +
diff --git a/packages/stablestudio-ui/vite.config.ts b/packages/stablestudio-ui/vite.config.ts index 3f3ae33..e44f857 100644 --- a/packages/stablestudio-ui/vite.config.ts +++ b/packages/stablestudio-ui/vite.config.ts @@ -47,6 +47,7 @@ export default defineConfig(({ mode }) => { "/view": redirectComfy, "/queue": redirectComfy, "/history": redirectComfy, + "/interrupt": redirectComfy, }, },