Agent管理页面手动触发预检时,先删缓存再预检
This commit is contained in:
@@ -48,6 +48,10 @@ pub struct PreflightResult {
|
|||||||
pub checks: Vec<CheckItem>,
|
pub checks: Vec<CheckItem>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clear_npm_env_cache() {
|
||||||
|
*NPM_ENV_CACHE.lock().unwrap() = None;
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn run_preflight(agent_type: AgentType) -> PreflightResult {
|
pub async fn run_preflight(agent_type: AgentType) -> PreflightResult {
|
||||||
let meta = registry::get_agent_meta(agent_type);
|
let meta = registry::get_agent_meta(agent_type);
|
||||||
debug_assert_eq!(meta.agent_type, agent_type);
|
debug_assert_eq!(meta.agent_type, agent_type);
|
||||||
|
|||||||
@@ -992,7 +992,13 @@ fn build_runtime_env_from_setting(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn acp_preflight(agent_type: AgentType) -> Result<PreflightResult, AcpError> {
|
pub async fn acp_preflight(
|
||||||
|
agent_type: AgentType,
|
||||||
|
force_refresh: Option<bool>,
|
||||||
|
) -> Result<PreflightResult, AcpError> {
|
||||||
|
if force_refresh.unwrap_or(false) {
|
||||||
|
preflight::clear_npm_env_cache();
|
||||||
|
}
|
||||||
Ok(preflight::run_preflight(agent_type).await)
|
Ok(preflight::run_preflight(agent_type).await)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 }))
|
setChecking((prev) => ({ ...prev, [agentType]: true }))
|
||||||
try {
|
try {
|
||||||
const [resultState, versionState] = await Promise.allSettled([
|
const [resultState, versionState] = await Promise.allSettled([
|
||||||
acpPreflight(agentType),
|
acpPreflight(agentType, forceRefresh),
|
||||||
acpDetectAgentLocalVersion(agentType),
|
acpDetectAgentLocalVersion(agentType),
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -4243,12 +4244,14 @@ export function AcpAgentSettings() {
|
|||||||
})}
|
})}
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
runPreflight(agent.agent_type).catch((err) => {
|
runPreflight(agent.agent_type, true).catch(
|
||||||
console.error(
|
(err) => {
|
||||||
"[Settings] single preflight failed:",
|
console.error(
|
||||||
err
|
"[Settings] single preflight failed:",
|
||||||
)
|
err
|
||||||
})
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<RefreshCw className="h-3 w-3 shrink-0" />
|
<RefreshCw className="h-3 w-3 shrink-0" />
|
||||||
|
|||||||
@@ -210,9 +210,13 @@ export async function acpReorderAgents(agentTypes: AgentType[]): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function acpPreflight(
|
export async function acpPreflight(
|
||||||
agentType: AgentType
|
agentType: AgentType,
|
||||||
|
forceRefresh?: boolean
|
||||||
): Promise<PreflightResult> {
|
): Promise<PreflightResult> {
|
||||||
return invoke("acp_preflight", { agentType })
|
return invoke("acp_preflight", {
|
||||||
|
agentType,
|
||||||
|
forceRefresh: forceRefresh ?? null,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function acpListAgentSkills(params: {
|
export async function acpListAgentSkills(params: {
|
||||||
|
|||||||
Reference in New Issue
Block a user