fix(dev): make sidecar resolution prefer the build's own profile

Dropping --release from staging/goose only fixed the build side; runtime
resolution still preferred release, so a dev box with stale release
artifacts would rebuild debug sidecars and then launch the stale release
ones anyway.

- desktop: command_search_dirs() now searches the dir matching this app's
  own build profile first (cfg!(debug_assertions)). A debug desktop build
  (tauri dev via `just staging`) prefers target/debug; a release build is
  unchanged. Add a unit test for the ordering.
- goose / goose-bg: prepend $PWD/target/debug to PATH so the agent and the
  `sprout` CLI its skills shell out to resolve to the same debug profile,
  not a stale release binary.

Co-authored-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: Wes <wesbillman@users.noreply.github.com>
This commit is contained in:
Wes
2026-06-08 15:55:57 -06:00
co-authored by Brain
parent acfcb72eef
commit ef6784cd60
2 changed files with 37 additions and 8 deletions
@@ -258,14 +258,23 @@ pub fn normalize_agent_args(command: &str, agent_args: Vec<String>) -> Vec<Strin
}
fn command_search_dirs() -> Vec<PathBuf> {
// Prefer the profile this app was built with: a debug desktop build (e.g.
// `tauri dev` via `just staging`) should pick up debug sidecars, not stale
// release artifacts left in `target/`.
let (preferred, fallback) = if cfg!(debug_assertions) {
("target/debug", "target/release")
} else {
("target/release", "target/debug")
};
let mut dirs = vec![
workspace_root_dir().join("target/release"),
workspace_root_dir().join("target/debug"),
workspace_root_dir().join(preferred),
workspace_root_dir().join(fallback),
];
if let Ok(current_dir) = std::env::current_dir() {
dirs.push(current_dir.join("target/release"));
dirs.push(current_dir.join("target/debug"));
dirs.push(current_dir.join(preferred));
dirs.push(current_dir.join(fallback));
}
if let Ok(exe_path) = std::env::current_exe() {
@@ -539,11 +548,31 @@ mod tests {
use std::path::PathBuf;
use super::{
classify_runtime, find_via_login_shell, managed_agent_avatar_url, normalize_agent_args,
CLAUDE_CODE_AVATAR_URL, CODEX_AVATAR_URL, GOOSE_AVATAR_URL, SPROUT_AGENT_AVATAR_URL,
classify_runtime, command_search_dirs, find_via_login_shell, managed_agent_avatar_url,
normalize_agent_args, CLAUDE_CODE_AVATAR_URL, CODEX_AVATAR_URL, GOOSE_AVATAR_URL,
SPROUT_AGENT_AVATAR_URL,
};
use crate::managed_agents::AcpAvailabilityStatus;
#[test]
fn search_dirs_prefer_this_builds_profile() {
let dirs = command_search_dirs();
let release = dirs
.iter()
.position(|d| d.ends_with("target/release"))
.expect("release dir present");
let debug = dirs
.iter()
.position(|d| d.ends_with("target/debug"))
.expect("debug dir present");
// This test binary is built debug, so debug must be searched first.
assert!(
debug < release,
"debug build must search target/debug first"
);
}
#[test]
fn resolves_known_avatar_for_bare_command() {
let avatar_url = managed_agent_avatar_url("goose").expect("goose avatar should resolve");
+2 -2
View File
@@ -547,7 +547,7 @@ goose relay="ws://localhost:3000" agents="1" heartbeat="0" prompt="" key="$SPROU
if [[ "{{heartbeat}}" != "0" ]]; then
env_args+=(SPROUT_ACP_HEARTBEAT_INTERVAL={{heartbeat}})
fi
exec env "${env_args[@]}" ./target/debug/sprout-acp
exec env PATH="$PWD/target/debug:$PATH" "${env_args[@]}" ./target/debug/sprout-acp
# Run a goose agent in the background (screen session named 'goose-agent-N')
goose-bg relay="ws://localhost:3000" agents="1" heartbeat="0" prompt="" key="$SPROUT_PRIVATE_KEY":
@@ -566,5 +566,5 @@ goose-bg relay="ws://localhost:3000" agents="1" heartbeat="0" prompt="" key="$SP
if [[ "{{heartbeat}}" != "0" ]]; then
env_args+=(SPROUT_ACP_HEARTBEAT_INTERVAL={{heartbeat}})
fi
screen -dmS goose-agent-{{agents}} bash -c "$(printf '%q ' env "${env_args[@]}") ./target/debug/sprout-acp"
screen -dmS goose-agent-{{agents}} bash -c "$(printf '%q ' env PATH="$PWD/target/debug:$PATH" "${env_args[@]}") ./target/debug/sprout-acp"
echo "Agent running in screen session 'goose-agent-{{agents}}'. Attach with: screen -r goose-agent-{{agents}}"