Fix dev mode sidecar launch and engine reload on mode change
1. Dev mode: use `uv run python` instead of bare `python` to ensure the project venv is used. Also use CARGO_MANIFEST_DIR to find the project root reliably. 2. Engine reload: changing remote.mode (local/managed/byok) now triggers a full engine reload. Previously only model and device changes triggered reload, so switching to Deepgram had no effect until the app was restarted. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -554,18 +554,27 @@ impl SidecarManager {
|
||||
// -- private helpers -------------------------------------------------------
|
||||
|
||||
fn build_dev_command(&self) -> Result<std::process::Command, String> {
|
||||
let mut cmd = std::process::Command::new("python");
|
||||
cmd.args(["-u", "-m", "backend.main_headless"]); // -u = unbuffered
|
||||
// Use `uv run` to ensure we use the project's venv, not system Python
|
||||
let mut cmd = std::process::Command::new("uv");
|
||||
cmd.args(["run", "python", "-u", "-m", "backend.main_headless"]);
|
||||
|
||||
// Try to find the project root (parent of src-tauri)
|
||||
if let Some(dirs) = DIRS.get() {
|
||||
let project_root = dirs
|
||||
.resource_dir
|
||||
.parent() // src-tauri
|
||||
.and_then(|p| p.parent()); // project root
|
||||
if let Some(root) = project_root {
|
||||
cmd.current_dir(root);
|
||||
}
|
||||
// Find the project root: try CARGO_MANIFEST_DIR first (set at compile time),
|
||||
// then fall back to resource_dir parent chain
|
||||
let manifest_dir = option_env!("CARGO_MANIFEST_DIR").map(std::path::PathBuf::from);
|
||||
let project_root = manifest_dir
|
||||
.as_ref()
|
||||
.and_then(|d| d.parent()) // src-tauri -> project root
|
||||
.or_else(|| {
|
||||
DIRS.get()
|
||||
.and_then(|d| d.resource_dir.parent())
|
||||
.and_then(|p| p.parent())
|
||||
});
|
||||
|
||||
if let Some(root) = project_root {
|
||||
eprintln!("[sidecar] Dev mode: working dir = {}", root.display());
|
||||
cmd.current_dir(root);
|
||||
} else {
|
||||
eprintln!("[sidecar] Dev mode: WARNING - could not determine project root");
|
||||
}
|
||||
|
||||
cmd.env("PYTHONUNBUFFERED", "1");
|
||||
|
||||
Reference in New Issue
Block a user