Skip to content

The open-source AI voice studio. Clone, dictate, create.

Implement server reuse logic and improve build script formatting

Jamie Pine1fdf61ca2e38
diff --git a/tauri/src-tauri/build.rs b/tauri/src-tauri/build.rs
index 69b18c37..f2ca1700 100644
--- a/tauri/src-tauri/build.rs
+++ b/tauri/src-tauri/build.rs
@@ -7,12 +7,15 @@ fn main() {
// Add Swift runtime library paths to RPATH
println!("cargo:rustc-link-arg=-Wl,-rpath,/usr/lib/swift");
println!("cargo:rustc-link-arg=-L/usr/lib/swift");
-
+
// Also try Xcode's Swift libraries
if let Ok(output) = Command::new("xcode-select").arg("-p").output() {
if output.status.success() {
let xcode_path = String::from_utf8_lossy(&output.stdout).trim().to_string();
- let swift_lib_path = format!("{}/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx", xcode_path);
+ let swift_lib_path = format!(
+ "{}/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx",
+ xcode_path
+ );
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", swift_lib_path);
println!("cargo:rustc-link-arg=-L{}", swift_lib_path);
}
@@ -38,14 +41,21 @@ fn main() {
let output = Command::new("xcrun")
.args([
"actool",
- "--compile", &gen_dir,
- "--output-format", "human-readable-text",
- "--output-partial-info-plist", &partial_plist,
- "--app-icon", "voicebox",
+ "--compile",
+ &gen_dir,
+ "--output-format",
+ "human-readable-text",
+ "--output-partial-info-plist",
+ &partial_plist,
+ "--app-icon",
+ "voicebox",
"--include-all-app-icons",
- "--target-device", "mac",
- "--minimum-deployment-target", "11.0",
- "--platform", "macosx",
+ "--target-device",
+ "mac",
+ "--minimum-deployment-target",
+ "11.0",
+ "--platform",
+ "macosx",
&icon_source,
])
.output();
@@ -66,7 +76,10 @@ fn main() {
}
}
} else {
- println!("cargo:warning=Icon source not found at {}, skipping icon compilation", icon_source);
+ println!(
+ "cargo:warning=Icon source not found at {}, skipping icon compilation",
+ icon_source
+ );
}
}
diff --git a/tauri/src-tauri/gen/Assets.car b/tauri/src-tauri/gen/Assets.car
index b7577eab..59f2c58a 100644
Binary files a/tauri/src-tauri/gen/Assets.car and b/tauri/src-tauri/gen/Assets.car differ
diff --git a/tauri/src-tauri/src/main.rs b/tauri/src-tauri/src/main.rs
index 4f61dbc4..2dda00aa 100644
--- a/tauri/src-tauri/src/main.rs
+++ b/tauri/src-tauri/src/main.rs
@@ -28,6 +28,57 @@ async fn start_server(
return Ok(format!("http://127.0.0.1:{}", SERVER_PORT));
}
+ // Check if a voicebox server is already running on our port (from previous session with keep_running=true)
+ #[cfg(unix)]
+ {
+ use std::process::Command;
+ if let Ok(output) = Command::new("lsof")
+ .args(["-i", &format!(":{}", SERVER_PORT), "-sTCP:LISTEN"])
+ .output()
+ {
+ let output_str = String::from_utf8_lossy(&output.stdout);
+ for line in output_str.lines().skip(1) {
+ let parts: Vec<&str> = line.split_whitespace().collect();
+ if parts.len() >= 2 {
+ let command = parts[0];
+ if command.contains("voicebox") {
+ println!("Found existing voicebox-server on port {}, reusing it", SERVER_PORT);
+ return Ok(format!("http://127.0.0.1:{}", SERVER_PORT));
+ }
+ }
+ }
+ }
+ }
+
+ #[cfg(windows)]
+ {
+ use std::process::Command;
+ if let Ok(output) = Command::new("netstat")
+ .args(["-ano"])
+ .output()
+ {
+ let output_str = String::from_utf8_lossy(&output.stdout);
+ for line in output_str.lines() {
+ if line.contains(&format!(":{}", SERVER_PORT)) && line.contains("LISTENING") {
+ if let Some(pid_str) = line.split_whitespace().last() {
+ if let Ok(pid) = pid_str.parse::<u32>() {
+ if let Ok(tasklist_output) = Command::new("tasklist")
+ .args(["/FI", &format!("PID eq {}", pid), "/FO", "CSV", "/NH"])
+ .output()
+ {
+ let tasklist_str = String::from_utf8_lossy(&tasklist_output.stdout);
+ if tasklist_str.to_lowercase().contains("voicebox") {
+ println!("Found existing voicebox-server on port {}, reusing it", SERVER_PORT);
+ return Ok(format!("http://127.0.0.1:{}", SERVER_PORT));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
// Kill any orphaned voicebox-server from previous session on legacy port 8000
// This handles upgrades from older versions that used a fixed port
#[cfg(unix)]