diff --git a/src-tauri/src/acp/preflight.rs b/src-tauri/src/acp/preflight.rs index cf34df7..45ee429 100644 --- a/src-tauri/src/acp/preflight.rs +++ b/src-tauri/src/acp/preflight.rs @@ -48,6 +48,10 @@ pub struct PreflightResult { pub checks: Vec, } +pub fn clear_npm_env_cache() { + *NPM_ENV_CACHE.lock().unwrap() = None; +} + pub async fn run_preflight(agent_type: AgentType) -> PreflightResult { let meta = registry::get_agent_meta(agent_type); debug_assert_eq!(meta.agent_type, agent_type); diff --git a/src-tauri/src/commands/acp.rs b/src-tauri/src/commands/acp.rs index 17baaf8..f0e63a1 100644 --- a/src-tauri/src/commands/acp.rs +++ b/src-tauri/src/commands/acp.rs @@ -992,7 +992,13 @@ fn build_runtime_env_from_setting( } #[tauri::command] -pub async fn acp_preflight(agent_type: AgentType) -> Result { +pub async fn acp_preflight( + agent_type: AgentType, + force_refresh: Option, +) -> Result { + if force_refresh.unwrap_or(false) { + preflight::clear_npm_env_cache(); + } Ok(preflight::run_preflight(agent_type).await) } diff --git a/src/components/settings/acp-agent-settings.tsx b/src/components/settings/acp-agent-settings.tsx index dd4f001..4f2a54d 100644 --- a/src/components/settings/acp-agent-settings.tsx +++ b/src/components/settings/acp-agent-settings.tsx @@ -2388,11 +2388,12 @@ export function AcpAgentSettings() { } }, []) - const runPreflight = useCallback(async (agentType: AgentType) => { + const runPreflight = useCallback( + async (agentType: AgentType, forceRefresh?: boolean) => { setChecking((prev) => ({ ...prev, [agentType]: true })) try { const [resultState, versionState] = await Promise.allSettled([ - acpPreflight(agentType), + acpPreflight(agentType, forceRefresh), acpDetectAgentLocalVersion(agentType), ]) @@ -4243,12 +4244,14 @@ export function AcpAgentSettings() { })} onClick={(event) => { event.stopPropagation() - runPreflight(agent.agent_type).catch((err) => { - console.error( - "[Settings] single preflight failed:", - err - ) - }) + runPreflight(agent.agent_type, true).catch( + (err) => { + console.error( + "[Settings] single preflight failed:", + err + ) + } + ) }} > diff --git a/src/lib/tauri.ts b/src/lib/tauri.ts index b8769ef..c475c6c 100644 --- a/src/lib/tauri.ts +++ b/src/lib/tauri.ts @@ -210,9 +210,13 @@ export async function acpReorderAgents(agentTypes: AgentType[]): Promise { } export async function acpPreflight( - agentType: AgentType + agentType: AgentType, + forceRefresh?: boolean ): Promise { - return invoke("acp_preflight", { agentType }) + return invoke("acp_preflight", { + agentType, + forceRefresh: forceRefresh ?? null, + }) } export async function acpListAgentSkills(params: {