fix: disable env check and one-click install on Windows to prevent protocol handler side effects

This commit is contained in:
Jason
2026-02-28 00:12:12 +08:00
parent 859f413756
commit f8c1f1736e
2 changed files with 193 additions and 171 deletions
+32 -19
View File
@@ -133,27 +133,40 @@ pub async fn get_tool_versions(
tools: Option<Vec<String>>,
wsl_shell_by_tool: Option<HashMap<String, WslShellPreferenceInput>>,
) -> Result<Vec<ToolVersion>, String> {
let requested: Vec<&str> = if let Some(tools) = tools.as_ref() {
let set: std::collections::HashSet<&str> = tools.iter().map(|s| s.as_str()).collect();
VALID_TOOLS
.iter()
.copied()
.filter(|t| set.contains(t))
.collect()
} else {
VALID_TOOLS.to_vec()
};
let mut results = Vec::new();
for tool in requested {
let pref = wsl_shell_by_tool.as_ref().and_then(|m| m.get(tool));
let tool_wsl_shell = pref.and_then(|p| p.wsl_shell.as_deref());
let tool_wsl_shell_flag = pref.and_then(|p| p.wsl_shell_flag.as_deref());
results.push(get_single_tool_version_impl(tool, tool_wsl_shell, tool_wsl_shell_flag).await);
// Windows: completely disable tool version detection to prevent
// accidentally launching apps (e.g. Claude Code) via protocol handlers.
#[cfg(target_os = "windows")]
{
let _ = (tools, wsl_shell_by_tool);
return Ok(Vec::new());
}
Ok(results)
#[cfg(not(target_os = "windows"))]
{
let requested: Vec<&str> = if let Some(tools) = tools.as_ref() {
let set: std::collections::HashSet<&str> = tools.iter().map(|s| s.as_str()).collect();
VALID_TOOLS
.iter()
.copied()
.filter(|t| set.contains(t))
.collect()
} else {
VALID_TOOLS.to_vec()
};
let mut results = Vec::new();
for tool in requested {
let pref = wsl_shell_by_tool.as_ref().and_then(|m| m.get(tool));
let tool_wsl_shell = pref.and_then(|p| p.wsl_shell.as_deref());
let tool_wsl_shell_flag = pref.and_then(|p| p.wsl_shell_flag.as_deref());
results.push(
get_single_tool_version_impl(tool, tool_wsl_shell, tool_wsl_shell_flag).await,
);
}
Ok(results)
}
}
/// 获取单个工具的版本信息(内部实现)