"""Small Linux integration fixes for the pinned community WebUI. Keep these transformations explicit and fail the image build if upstream moves the expected code. That prevents a future upstream update from silently producing a half-patched console. """ from pathlib import Path import sys root = Path(sys.argv[1]) app_js = root / "static" / "app.js" index_html = root / "static" / "index.html" server_py = root / "server.py" def replace_once(path: Path, old: str, new: str) -> None: text = path.read_text(encoding="utf-8") if text.count(old) != 1: raise RuntimeError(f"expected exactly one patch marker in {path}: {old[:80]!r}") path.write_text(text.replace(old, new, 1), encoding="utf-8") # The published UI calls refreshArt() during startup, but does not define it. # Athena does not install the Windows-only stable-diffusion.cpp helper, so show # that state honestly and keep the optional controls inert instead of crashing # the whole page. art_marker = ''' $("artDirAdd").addEventListener("click", function () { ''' art_fix = ''' function refreshArt() { return api("/api/art/status").then(function (data) { STATE.art = data; var installed = !!data.installed; var supported = !!data.supported; $("artState").textContent = data.busy || (installed ? "installed" : (supported ? "not installed" : "not available on Linux")); $("artState").dataset.s = data.busy ? "busy" : (installed ? "ready" : "missing"); $("artInstall").disabled = !!data.busy || !supported; $("artInstall").textContent = installed ? "Reinstall" : "Install"; $("setArtAuto").checked = !!data.auto; $("setArtAuto").disabled = !installed; $("setArtModel").innerHTML = (data.models || []).length ? data.models.map(function (m) { return ''; }).join("") : ''; if (data.selected) $("setArtModel").value = data.selected; $("setArtModel").disabled = !installed; $("artDir").disabled = !supported; $("artDirAdd").disabled = !supported; $("artDirs").textContent = supported ? ((data.dirs || []).length ? "Also scanning: " + data.dirs.join(" · ") : "No extra folders configured.") : "The community release only provides the cover-art installer for Windows; song generation is unaffected."; $("artCatalog").innerHTML = ""; return data; }).catch(function (error) { $("artState").textContent = "unavailable"; $("artInstall").disabled = true; $("artDirs").textContent = error.message; }); } $("artDirAdd").addEventListener("click", function () { ''' replace_once(app_js, art_marker, art_fix) # YuE2 natively supports an empty lyric string for true instrumentals. The # community server rejected that valid request even though the browser did not. replace_once( server_py, ''' if not body.style.strip() or not body.lyrics.strip(): raise HTTPException(400, "A style prompt and lyrics are both required") ''', ''' if not body.style.strip(): raise HTTPException(400, "A style prompt is required") ''', ) replace_once( index_html, '''Lyrics section tags on their own line''', '''Lyrics section tags on their own line · leave empty for a true instrumental''', )