fix(modules-preview): fix bot builds, scaling recognition, and add live build progress bar

This commit is contained in:
Дмитрий committed 2026-11-03 16:02:41 +05:00
1 parent be644f8c54
commit 221f4a93d3
5 files changed
+238 -53

No files matched your search

+10 -1
View File
@@ -936,7 +936,16 @@ pub fn parse_and_validate_github_url(url_str: &str) -> Result<(String, String, O
/// - Symlinks and junctions rejected
/// - Strictly read-only analysis: NO execution of CMake, build scripts, or SQL migrations
pub fn analyze_github_repository(url_str: &str, cache_base_dir: Option<&Path>) -> Result<CompatibilityReport> {
let (owner, repo, ref_opt) = parse_and_validate_github_url(url_str)?;
let (mut owner, mut repo, mut ref_opt) = parse_and_validate_github_url(url_str)?;
// Redirect upstream unadapted playerbots to verified CoA fork
if (owner.eq_ignore_ascii_case("Zyth45") || owner.eq_ignore_ascii_case("azerothcore")) && repo.eq_ignore_ascii_case("mod-playerbots") {
owner = "Corfirean".into();
repo = "mod-playerbots".into();
if ref_opt.is_none() {
ref_opt = Some("coa".into());
}
}
let base_cache = match cache_base_dir {
Some(p) => p.to_path_buf(),
+44 -20
View File
@@ -261,27 +261,33 @@ pub fn resolve_module_identity(source_dir: &Path) -> (String, String, Option<Str
(raw_name, None)
};
let module_id = canonical_raw.trim_start_matches("mod-").replace('_', "-");
let raw_id = canonical_raw.trim_start_matches("mod-").replace('_', "-");
let display_name = match module_id.as_str() {
"npc-buffer" => "NPC Buffer".to_string(),
"ah-bot" => "Auction House Bot".to_string(),
"guildhouse" => "Guildhouse".to_string(),
"congrats-on-level" => "Congrats on Level".to_string(),
"npc-enchanter" => "NPC Enchanter".to_string(),
"reward-played-time" => "Reward Played Time".to_string(),
"transmog" => "Transmog".to_string(),
"solocraft" => "Solocraft".to_string(),
"autobalance" => "AutoBalance".to_string(),
"individual-progression" => "Individual Progression".to_string(),
"ale" => "AzerothCore Lua Engine (ALE)".to_string(),
"coa-playerbots" | "playerbots" | "companions" => "CoA Companions".to_string(),
"squid-playerbots" | "squid" => "SQUID's Playerbots".to_string(),
"coa-content-scaling" | "content-scaling" | "scaling" => "Content Scaling".to_string(),
"custom-races" => "Custom Races".to_string(),
"timeistime" => "TimeIsTime".to_string(),
let (module_id, display_name) = match raw_id.as_str() {
"coa-content-scaling" | "content-scaling" | "scaling" => {
("content-scaling".to_string(), "Content Scaling".to_string())
}
"coa-playerbots" | "companions" => {
("companions".to_string(), "CoA Companions".to_string())
}
"squid-playerbots" | "playerbots" | "squid" => {
("playerbots".to_string(), "SQUID's Playerbots".to_string())
}
"npc-buffer" => ("npc-buffer".to_string(), "NPC Buffer".to_string()),
"ah-bot" => ("ah-bot".to_string(), "Auction House Bot".to_string()),
"guildhouse" => ("guildhouse".to_string(), "Guildhouse".to_string()),
"congrats-on-level" => ("congrats-on-level".to_string(), "Congrats on Level".to_string()),
"npc-enchanter" => ("npc-enchanter".to_string(), "NPC Enchanter".to_string()),
"reward-played-time" => ("reward-played-time".to_string(), "Reward Played Time".to_string()),
"transmog" => ("transmog".to_string(), "Transmog".to_string()),
"solocraft" => ("solocraft".to_string(), "Solocraft".to_string()),
"autobalance" => ("autobalance".to_string(), "AutoBalance".to_string()),
"individual-progression" => ("individual-progression".to_string(), "Individual Progression".to_string()),
"ale" => ("ale".to_string(), "AzerothCore Lua Engine (ALE)".to_string()),
"custom-races" => ("custom-races".to_string(), "Custom Races".to_string()),
"timeistime" | "time-is-time" => ("time-is-time".to_string(), "TimeIsTime".to_string()),
other => {
other.split('-')
let pretty = other.split('-')
.map(|word| {
let mut chars = word.chars();
match chars.next() {
@@ -290,7 +296,8 @@ pub fn resolve_module_identity(source_dir: &Path) -> (String, String, Option<Str
}
})
.collect::<Vec<_>>()
.join(" ")
.join(" ");
(other.to_string(), pretty)
}
};
@@ -489,6 +496,23 @@ pub fn build_module_from_source(
};
let dest = staging_src.join(&dest_file_name);
fs::copy(cpp, &dest)?;
// Resilient compatibility patching for older / cached mod-coa-playerbots
if dest_file_name == "BotMgr.cpp" {
if let Ok(content) = fs::read_to_string(&dest) {
if content.contains("_GetPurchasedTabsSize") || content.contains("_CreateNewBankTab") {
let patched = content
.replace("guild->_GetPurchasedTabsSize()", "guild->GetPurchasedTabsSize()")
.replace("if (guild->_GetPurchasedTabsSize() == 0)\n guild->_CreateNewBankTab();", "guild->EnsureFirstBankTab();")
.replace("if (guild->_GetPurchasedTabsSize() == 0)\r\n guild->_CreateNewBankTab();", "guild->EnsureFirstBankTab();")
.replace("guild->_CreateNewBankTab()", "guild->EnsureFirstBankTab()")
.replace("Guild::BankTab const* tab = guild->GetBankTab(tabId);\n if (!tab)\n continue;\n for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)\n if (Item const* item = tab->GetItem(slotId))", "for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)\n if (Item const* item = guild->GetBankItem(tabId, slotId))")
.replace("Guild::BankTab const* tab = guild->GetBankTab(tabId);\r\n if (!tab)\r\n continue;\r\n for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)\r\n if (Item const* item = tab->GetItem(slotId))", "for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)\r\n if (Item const* item = guild->GetBankItem(tabId, slotId))");
let _ = fs::write(&dest, patched);
}
}
}
staged_cpp_paths.push(dest.to_string_lossy().replace('\\', "/"));
}
+38 -15
View File
@@ -249,19 +249,39 @@ fn list_in(cat: &[Entry], root: &Path) -> Vec<ModuleView> {
.or_else(|| r.plugins.get(&e.id.replace('-', "_")))
.or_else(|| r.plugins.get(&format!("mod-{}", e.id)))
.or_else(|| r.plugins.get(&format!("mod-coa-{}", e.id)))
.or_else(|| r.plugins.get(&format!("coa-{}", e.id)))
.or_else(|| r.plugins.get(&format!("coa_{}", e.id)))
.or_else(|| match e.id.as_str() {
"content-scaling" => r.plugins.get("coa-content-scaling").or_else(|| r.plugins.get("mod-coa-content-scaling")),
"companions" => r.plugins.get("coa-playerbots").or_else(|| r.plugins.get("mod-coa-playerbots")),
"playerbots" => r.plugins.get("squid-playerbots").or_else(|| r.plugins.get("mod-playerbots")),
_ => None,
})
});
let dll_present = root.join("plugins").join(format!("{}.dll", e.id)).is_file()
|| root.join("plugins").join(format!("{}.dll", e.id.replace('-', "_"))).is_file()
|| root.join("plugins").join(format!("mod-{}.dll", e.id)).is_file()
|| root.join("plugins").join(format!("mod-{}.dll", e.id.replace('-', "_"))).is_file()
|| root.join("plugins").join(format!("mod-coa-{}.dll", e.id)).is_file()
|| root.join("plugins").join(format!("mod_coa_{}.dll", e.id.replace('-', "_"))).is_file()
|| root.join(".manager/plugins").join(format!("{}.dll", e.id)).is_file()
|| root.join(".manager/plugins").join(format!("{}.dll", e.id.replace('-', "_"))).is_file()
|| root.join(".manager/plugins").join(format!("mod-{}.dll", e.id)).is_file()
|| root.join(".manager/plugins").join(format!("mod-{}.dll", e.id.replace('-', "_"))).is_file()
|| root.join(".manager/plugins").join(format!("mod-coa-{}.dll", e.id)).is_file()
|| root.join(".manager/plugins").join(format!("mod_coa_{}.dll", e.id.replace('-', "_"))).is_file();
let dll_candidates = [
root.join("plugins").join(format!("{}.dll", e.id)),
root.join("plugins").join(format!("{}.dll", e.id.replace('-', "_"))),
root.join("plugins").join(format!("coa-{}.dll", e.id)),
root.join("plugins").join(format!("coa_{}.dll", e.id.replace('-', "_"))),
root.join("plugins").join(format!("mod-{}.dll", e.id)),
root.join("plugins").join(format!("mod-{}.dll", e.id.replace('-', "_"))),
root.join("plugins").join(format!("mod-coa-{}.dll", e.id)),
root.join("plugins").join(format!("mod_coa_{}.dll", e.id.replace('-', "_"))),
// Subdirectory checks (plugins/{id}/{id}.dll)
root.join("plugins").join(&e.id).join(format!("{}.dll", e.id)),
root.join("plugins").join(format!("coa-{}", e.id)).join(format!("coa-{}.dll", e.id)),
root.join("plugins").join(format!("mod-{}", e.id)).join(format!("mod-{}.dll", e.id)),
root.join("plugins").join(format!("mod-coa-{}", e.id)).join(format!("mod-coa-{}.dll", e.id)),
// Special alias subdirectories
root.join("plugins").join("coa-content-scaling").join("coa-content-scaling.dll"),
root.join("plugins").join("coa-playerbots").join("coa-playerbots.dll"),
// .manager/plugins checks
root.join(".manager/plugins").join(format!("{}.dll", e.id)),
root.join(".manager/plugins").join(format!("coa-{}.dll", e.id)),
root.join(".manager/plugins").join(format!("mod-coa-{}.dll", e.id)),
];
let dll_present = dll_candidates.iter().any(|p| p.is_file());
let is_dynamic = plugin_entry.is_some() || dll_present;
// 2. Classify ComponentType and determine installation strictly
@@ -279,18 +299,21 @@ fn list_in(cat: &[Entry], root: &Path) -> Vec<ModuleView> {
let se_plugin = plugin_reg.as_ref().and_then(|r| {
r.plugins.get("content-scaling")
.or_else(|| r.plugins.get("content_scaling"))
.or_else(|| r.plugins.get("coa-content-scaling"))
.or_else(|| r.plugins.get("mod-coa-content-scaling"))
});
let se_dll = root.join("plugins").join("content-scaling.dll").is_file()
|| root.join("plugins").join("content_scaling.dll").is_file()
|| root.join("plugins").join("content-scaling").join("content-scaling.dll").is_file()
|| root.join("plugins").join("coa-content-scaling").join("coa-content-scaling.dll").is_file()
|| root.join("plugins").join("coa-content-scaling.dll").is_file()
|| root.join("plugins").join("mod-coa-content-scaling.dll").is_file()
|| root.join("plugins").join("mod_coa_content_scaling.dll").is_file()
|| root.join(".manager/plugins").join("content-scaling.dll").is_file()
|| root.join(".manager/plugins").join("coa-content-scaling.dll").is_file()
|| root.join(".manager/plugins").join("mod-coa-content-scaling.dll").is_file();
se_plugin.is_some() || se_dll || (!is_modular_host && installed_commits.contains_key("scaling"))
};
let has_content = is_scaling_installed && (conf.is_file() || dist.is_file());
let has_content = is_scaling_installed;
(ComponentType::ContentPack, has_content, false)
} else if e.id == "client-compat" {
(ComponentType::LogicalFeature, true, false)
+23 -12
View File
@@ -2944,6 +2944,7 @@ async fn preview_register_test_realm(
#[tauri::command]
async fn preview_build_module(
app: AppHandle,
state: State<'_, AppState>,
realm_id: String,
source_url_or_path: String,
@@ -2958,22 +2959,32 @@ async fn preview_build_module(
let realm_root = path_of(&state, &realm_id)?;
let cache_dir = data_dir().join("github_cache");
let app_clone = app.clone();
let progress_cb: Box<dyn Fn(coa_core::build_engine::BuildProgressEvent) + Send + Sync> =
Box::new(move |event| {
let _ = app_clone.emit("preview_build_progress", &event);
});
blocking(move || {
let source_dir = if source_url_or_path.starts_with("http://") || source_url_or_path.starts_with("https://") {
let (owner, repo, _) = coa_core::analyzer::parse_and_validate_github_url(&source_url_or_path)?;
let repo_cache = cache_dir.join("github").join(&owner).join(&repo);
let _ = coa_core::analyzer::analyze_github_module_for_realm(&source_url_or_path, &realm_root, Some(&cache_dir))?;
let mut found = None;
if let Ok(entries) = std::fs::read_dir(&repo_cache) {
for entry in entries.flatten() {
if entry.path().is_dir() && entry.path().join(".coa_tree_digest").is_file() {
found = Some(entry.path());
break;
let report = coa_core::analyzer::analyze_github_module_for_realm(&source_url_or_path, &realm_root, Some(&cache_dir))?;
let p = PathBuf::from(&report.repository_path);
if p.is_dir() {
p
} else {
let (owner, repo, _) = coa_core::analyzer::parse_and_validate_github_url(&source_url_or_path)?;
let repo_cache = cache_dir.join("github").join(&owner).join(&repo);
let mut found = None;
if let Ok(entries) = std::fs::read_dir(&repo_cache) {
for entry in entries.flatten() {
if entry.path().is_dir() && entry.path().join(".coa_tree_digest").is_file() {
found = Some(entry.path());
break;
}
}
}
found.ok_or_else(|| coa_core::Error::Invalid("Failed to locate cached repository sources after intake".into()))?
}
found.ok_or_else(|| coa_core::Error::Invalid("Failed to locate cached repository sources after intake".into()))?
} else {
let p = PathBuf::from(&source_url_or_path);
if p.exists() {
@@ -3000,7 +3011,7 @@ async fn preview_build_module(
}
};
coa_core::build_engine::build_module_from_source(&source_dir, &realm_root, None, None)
coa_core::build_engine::build_module_from_source(&source_dir, &realm_root, None, Some(progress_cb))
.map_err(Into::into)
})
.await
+123 -5
View File
@@ -265,7 +265,7 @@ const VERIFIED_CATALOG: VerifiedCatalogModule[] = [
{
id: "playerbots",
name: "SQUID's Playerbots",
repo: "https://github.com/Zyth45/mod-playerbots",
repo: "https://github.com/Corfirean/mod-playerbots",
category: "official",
description: {
ru: "Альтернативная система ботов со случайными ботами и полным ИИ.",
@@ -625,6 +625,12 @@ export function ModulesPage({
const [building, setBuilding] = useState(false);
const [buildResult, setBuildResult] = useState<BuildResult | null>(null);
const [buildLogs, setBuildLogs] = useState<string[]>([]);
const [buildProgress, setBuildProgress] = useState<{
step: string;
progress_pct: number;
message: string;
elapsedSeconds: number;
} | null>(null);
// Installation & SQL confirmation modal
const [installing, setInstalling] = useState(false);
@@ -840,7 +846,39 @@ export function ModulesPage({
setBuilding(true);
setActiveTab("builds");
setBuildLogs(["[CSM Controlled Build Engine] Initializing build environment..."]);
setBuildProgress({
step: "PREPARING",
progress_pct: 10,
message: locale === "ru" ? "Инициализация среды сборки MSVC и SDK..." : "Initializing MSVC and SDK build environment...",
elapsedSeconds: 0,
});
const startTime = Date.now();
const timer = setInterval(() => {
const elapsed = (Date.now() - startTime) / 1000;
setBuildProgress((prev) => (prev ? { ...prev, elapsedSeconds: elapsed } : null));
}, 100);
let unlisten: (() => void) | null = null;
try {
try {
unlisten = await listen<{ step: string; progress_pct: number; message: string; log_line?: string }>(
"preview_build_progress",
(event) => {
const p = event.payload;
setBuildProgress((prev) => ({
step: p.step,
progress_pct: p.progress_pct,
message: p.message,
elapsedSeconds: prev ? prev.elapsedSeconds : (Date.now() - startTime) / 1000,
}));
if (p.log_line) {
setBuildLogs((logs) => [...logs, p.log_line!]);
}
}
);
} catch {}
setBuildLogs((prev) => [
...prev,
`Target module: ${target}`,
@@ -850,6 +888,12 @@ export function ModulesPage({
setBuildResult(res);
setBuildLogs(res.log_output);
if (res.success) {
setBuildProgress({
step: "SUCCESS",
progress_pct: 100,
message: locale === "ru" ? "Сборка завершена успешно" : "Build completed successfully",
elapsedSeconds: (Date.now() - startTime) / 1000,
});
setNotification(
locale === "ru"
? `Сборка успешно завершена! DLL '${res.display_name || res.module_id}' квалифицирована: ${res.dll_sha256?.substring(0, 16)}...`
@@ -867,6 +911,8 @@ export function ModulesPage({
setAnalysisError(errText);
setBuildLogs((prev) => [...prev, `[FATAL BUILD ERROR]: ${errText}`]);
} finally {
clearInterval(timer);
unlisten?.();
setBuilding(false);
}
}
@@ -939,7 +985,8 @@ export function ModulesPage({
}
const isScalingInstalled = Boolean(
modules?.some((m) => m.id === "content-scaling" && m.installed)
modules?.some((m) => (m.id === "content-scaling" || m.id === "coa-content-scaling") && m.installed) ||
installedPlugins?.some((p) => p.id === "content-scaling" || p.id === "coa-content-scaling")
);
const installedModules = (modules?.filter((m) => m.installed) ?? []).filter((m) => {
@@ -1336,6 +1383,37 @@ export function ModulesPage({
</button>
</div>
{/* Sticky Active Build Banner when user is outside the builds tab */}
{building && buildProgress && activeTab !== "builds" && (
<div
onClick={() => setActiveTab("builds")}
className="cursor-pointer rounded-lg border border-gold/40 bg-gold/10 p-3 flex items-center justify-between shadow transition-colors hover:bg-gold/15 animate-in fade-in"
>
<div className="flex items-center gap-3">
<Loader2 className="h-4 w-4 animate-spin text-gold" />
<div>
<div className="flex items-center gap-2">
<span className="text-xs font-semibold uppercase tracking-wider text-gold">
{locale === "ru" ? "Идет сборка модуля" : "Building module"}
</span>
<span className="text-xs text-zinc-300 font-mono">[{buildProgress.step}]</span>
<span className="text-xs text-muted">— {buildProgress.message}</span>
</div>
</div>
</div>
<div className="flex items-center gap-3">
<div className="w-32 h-1.5 overflow-hidden rounded-full bg-black/60 border border-line/40">
<div
className="h-full bg-gradient-to-r from-amber-500 to-yellow-400 transition-all duration-300"
style={{ width: `${Math.max(5, Math.min(100, buildProgress.progress_pct))}%` }}
/>
</div>
<span className="font-mono text-xs font-bold text-gold">{buildProgress.progress_pct}%</span>
<span className="text-[11px] font-mono text-zinc-400">({buildProgress.elapsedSeconds.toFixed(1)}s)</span>
</div>
</div>
)}
{/* TAB 0: INSTALLED MODULES */}
{activeTab === "installed" && (
<div className="space-y-4">
@@ -1851,10 +1929,20 @@ export function ModulesPage({
<div className="grid gap-3 sm:grid-cols-2">
{filteredVerifiedCatalog.map((item) => {
const matchedModule = modules?.find(
(m) => m.id === item.id || m.name.toLowerCase() === item.name.toLowerCase()
(m) =>
m.id === item.id ||
m.id === `coa-${item.id}` ||
m.id === `mod-coa-${item.id}` ||
m.name.toLowerCase() === item.name.toLowerCase()
);
const isInstalled = Boolean(matchedModule?.installed);
const isEnabled = Boolean(matchedModule?.enabled);
const matchedPlugin = installedPlugins?.find(
(p) =>
p.id === item.id ||
p.id === `coa-${item.id}` ||
p.name.toLowerCase() === item.name.toLowerCase()
);
const isInstalled = Boolean(matchedModule?.installed || matchedPlugin);
const isEnabled = Boolean(matchedModule?.enabled ?? matchedPlugin?.enabled ?? false);
return (
<Card key={item.id} className="border-line bg-card p-4 flex flex-col justify-between space-y-3 hover:border-gold/30 transition-colors">
@@ -2474,6 +2562,36 @@ export function ModulesPage({
{/* TAB 4: BUILDS & MSVC LOGS */}
{activeTab === "builds" && (
<div className="space-y-4">
{/* Active Build Progress Bar */}
{building && buildProgress && (
<Card className="border border-gold/40 bg-gold/5 p-4 space-y-3 shadow-lg">
<div className="flex items-center justify-between text-xs">
<div className="flex items-center gap-2">
<Loader2 className="h-4 w-4 animate-spin text-gold" />
<span className="font-semibold text-ink uppercase tracking-wider">{buildProgress.step}</span>
<span className="text-zinc-300">— {buildProgress.message}</span>
</div>
<div className="flex items-center gap-2 font-mono">
<span className="text-gold font-bold">{buildProgress.progress_pct}%</span>
<span className="text-zinc-400">({buildProgress.elapsedSeconds.toFixed(1)}s)</span>
</div>
</div>
{/* Animated Progress Track */}
<div className="h-2 w-full overflow-hidden rounded-full bg-black/60 border border-line/40">
<div
className="h-full bg-gradient-to-r from-amber-500 via-yellow-400 to-amber-300 transition-all duration-300 ease-out"
style={{ width: `${Math.max(5, Math.min(100, buildProgress.progress_pct))}%` }}
/>
</div>
<div className="flex items-center justify-between text-[11px] text-zinc-400 pt-1 border-t border-line/30 font-sans">
<span>{locale === "ru" ? "Используется Cl.exe & Ninja (MSVC x64 /MD)" : "Using Cl.exe & Ninja (MSVC x64 /MD)"}</span>
<span>{locale === "ru" ? "Прогресс сборки и линковки DLL" : "DLL build and link progress"}</span>
</div>
</Card>
)}
{/* Build Result Card */}
{buildResult && (
<Card