feat(ui): gray out enrich-hf-llm when no hf_url, add backend fast-fail, rename labels across locales, reposition menu item

This commit is contained in:
Will Miao
2026-07-06 00:34:18 +08:00
parent d0e8938039
commit 308d8f71b8
15 changed files with 95 additions and 66 deletions

View File

@@ -781,7 +781,7 @@
"complete": "Automatische Organisation abgeschlossen",
"error": "Fehler: {error}"
},
"enrichHfAgent": "Metadaten mit KI anreichern"
"enrichHfAgent": "HF-Metadaten mit KI anreichern"
},
"contextMenu": {
"refreshMetadata": "Civitai-Daten aktualisieren",
@@ -806,7 +806,7 @@
"viewAllLoras": "Alle LoRAs anzeigen",
"downloadMissingLoras": "Fehlende LoRAs herunterladen",
"deleteRecipe": "Rezept löschen",
"enrichHfAgent": "Metadaten mit KI anreichern"
"enrichHfAgent": "HF-Metadaten mit KI anreichern"
}
},
"recipes": {

View File

@@ -781,7 +781,7 @@
"complete": "Auto-organize complete",
"error": "Error: {error}"
},
"enrichHfAgent": "Enrich Metadata (AI)"
"enrichHfAgent": "Enrich HF Metadata (AI)"
},
"contextMenu": {
"refreshMetadata": "Refresh Civitai Data",
@@ -806,7 +806,7 @@
"viewAllLoras": "View All LoRAs",
"downloadMissingLoras": "Download Missing LoRAs",
"deleteRecipe": "Delete Recipe",
"enrichHfAgent": "Enrich Metadata (AI)"
"enrichHfAgent": "Enrich HF Metadata (AI)"
}
},
"recipes": {

View File

@@ -781,7 +781,7 @@
"complete": "Auto-organización completada",
"error": "Error: {error}"
},
"enrichHfAgent": "Enriquecer metadatos (IA)"
"enrichHfAgent": "Enriquecer metadatos HF (IA)"
},
"contextMenu": {
"refreshMetadata": "Actualizar datos de Civitai",
@@ -806,7 +806,7 @@
"viewAllLoras": "Ver todos los LoRAs",
"downloadMissingLoras": "Descargar LoRAs faltantes",
"deleteRecipe": "Eliminar receta",
"enrichHfAgent": "Enriquecer metadatos (IA)"
"enrichHfAgent": "Enriquecer metadatos HF (IA)"
}
},
"recipes": {

View File

@@ -781,7 +781,7 @@
"complete": "Auto-organisation terminée",
"error": "Erreur : {error}"
},
"enrichHfAgent": "Enrichir les métadonnées (IA)"
"enrichHfAgent": "Enrichir les métadonnées HF (IA)"
},
"contextMenu": {
"refreshMetadata": "Actualiser les données Civitai",
@@ -806,7 +806,7 @@
"viewAllLoras": "Voir tous les LoRAs",
"downloadMissingLoras": "Télécharger les LoRAs manquants",
"deleteRecipe": "Supprimer la recipe",
"enrichHfAgent": "Enrichir les métadonnées (IA)"
"enrichHfAgent": "Enrichir les métadonnées HF (IA)"
}
},
"recipes": {

View File

@@ -781,7 +781,7 @@
"complete": "ארגון אוטומטי הושלם",
"error": "שגיאה: {error}"
},
"enrichHfAgent": "העשרת מטא-דאטה (AI)"
"enrichHfAgent": "העשרת HF מטא-דאטה (AI)"
},
"contextMenu": {
"refreshMetadata": "רענן נתוני Civitai",
@@ -806,7 +806,7 @@
"viewAllLoras": "הצג את כל ה-LoRAs",
"downloadMissingLoras": "הורד LoRAs חסרים",
"deleteRecipe": "מחק מתכון",
"enrichHfAgent": "העשרת מטא-דאטה (AI)"
"enrichHfAgent": "העשרת HF מטא-דאטה (AI)"
}
},
"recipes": {

View File

@@ -781,7 +781,7 @@
"complete": "自動整理が完了しました",
"error": "エラー:{error}"
},
"enrichHfAgent": "メタデータをAIで補完"
"enrichHfAgent": "HF メタデータをAIで補完"
},
"contextMenu": {
"refreshMetadata": "Civitaiデータを更新",
@@ -806,7 +806,7 @@
"viewAllLoras": "すべてのLoRAを表示",
"downloadMissingLoras": "不足しているLoRAをダウンロード",
"deleteRecipe": "レシピを削除",
"enrichHfAgent": "メタデータをAIで補完"
"enrichHfAgent": "HF メタデータをAIで補完"
}
},
"recipes": {

View File

@@ -781,7 +781,7 @@
"complete": "자동 정리 완료",
"error": "오류: {error}"
},
"enrichHfAgent": "AI로 메타데이터 보강"
"enrichHfAgent": "HF AI로 메타데이터 보강"
},
"contextMenu": {
"refreshMetadata": "Civitai 데이터 새로고침",
@@ -806,7 +806,7 @@
"viewAllLoras": "모든 LoRA 보기",
"downloadMissingLoras": "누락된 LoRA 다운로드",
"deleteRecipe": "레시피 삭제",
"enrichHfAgent": "AI로 메타데이터 보강"
"enrichHfAgent": "HF AI로 메타데이터 보강"
}
},
"recipes": {

View File

@@ -781,7 +781,7 @@
"complete": "Автоматическая организация завершена",
"error": "Ошибка: {error}"
},
"enrichHfAgent": "Обогатить метаданные (ИИ)"
"enrichHfAgent": "Обогатить HF метаданные (ИИ)"
},
"contextMenu": {
"refreshMetadata": "Обновить данные Civitai",
@@ -806,7 +806,7 @@
"viewAllLoras": "Посмотреть все LoRAs",
"downloadMissingLoras": "Загрузить отсутствующие LoRAs",
"deleteRecipe": "Удалить рецепт",
"enrichHfAgent": "Обогатить метаданные (ИИ)"
"enrichHfAgent": "Обогатить HF метаданные (ИИ)"
}
},
"recipes": {

View File

@@ -781,7 +781,7 @@
"complete": "自动整理已完成",
"error": "错误:{error}"
},
"enrichHfAgent": "AI 元数据增强"
"enrichHfAgent": "AI HF 元数据增强"
},
"contextMenu": {
"refreshMetadata": "刷新 Civitai 数据",
@@ -806,7 +806,7 @@
"viewAllLoras": "查看所有 LoRA",
"downloadMissingLoras": "下载缺失的 LoRA",
"deleteRecipe": "删除配方",
"enrichHfAgent": "AI 元数据增强"
"enrichHfAgent": "AI HF 元数据增强"
}
},
"recipes": {

View File

@@ -781,7 +781,7 @@
"complete": "自動整理完成",
"error": "錯誤:{error}"
},
"enrichHfAgent": "AI 中繼資料增強"
"enrichHfAgent": "AI HF 中繼資料增強"
},
"contextMenu": {
"refreshMetadata": "刷新 Civitai 資料",
@@ -806,7 +806,7 @@
"viewAllLoras": "檢視全部 LoRA",
"downloadMissingLoras": "下載缺少的 LoRA",
"deleteRecipe": "刪除配方",
"enrichHfAgent": "AI 中繼資料增強"
"enrichHfAgent": "AI HF 中繼資料增強"
}
},
"recipes": {

View File

@@ -242,6 +242,7 @@ class AgentService:
total = len(model_paths)
processed = 0
success_count = 0
skipped_count = 0
updated_models: List[Dict[str, Any]] = []
errors: List[str] = []
post_processor = PostProcessor()
@@ -261,10 +262,21 @@ class AgentService:
skill_name, processed + 1, total, model_filename,
)
updated_data: Dict[str, Any] = {}
skip_model = False
try:
from ...metadata_ops import read_metadata
metadata = await read_metadata(model_path)
# Fast-fail: enrich_hf_metadata requires hf_url to have HF README context
if skill_name == "enrich_hf_metadata" and not metadata.get("hf_url", ""):
logger.info(
"[%s] SKIP %s — no hf_url in metadata",
skill_name, model_filename,
)
skipped_count += 1
skip_model = True
if not skip_model:
prompt_vars: Dict[str, Any] = {"model_path": model_path}
if skill.llm_required and llm_configured:
prompt_vars = await self._build_prompt_context(
@@ -321,6 +333,7 @@ class AgentService:
await self._emit_progress(
progress_callback, skill_name, status="processing",
total=total, processed=processed, success=success_count,
skipped=skipped_count,
current_path=model_path,
updated_data=updated_data,
)
@@ -329,12 +342,13 @@ class AgentService:
success=success_count > 0,
updated_models=updated_models,
errors=errors,
summary=f"Processed {processed}/{total} models, {success_count} succeeded",
summary=f"Processed {processed}/{total} models, {success_count} succeeded, {skipped_count} skipped",
)
await self._emit_progress(
progress_callback, skill_name, status="completed",
total=total, processed=processed, success=success_count,
skipped=skipped_count,
updated_models=updated_models, errors=errors, summary=result.summary,
)

View File

@@ -40,6 +40,12 @@
margin: 3px 0;
}
.context-menu-item.disabled {
opacity: 0.4;
cursor: not-allowed;
pointer-events: none;
}
.context-menu-item.delete-item {
color: var(--danger-color);
}

View File

@@ -27,8 +27,9 @@ export class BaseContextMenu {
const menuItem = e.target.closest('.context-menu-item');
if (!menuItem || !this.currentCard) return;
// Ignore clicks on submenu trigger (has-submenu parent)
// Ignore clicks on submenu trigger (has-submenu parent) or disabled items
if (menuItem.classList.contains('has-submenu')) return;
if (menuItem.classList.contains('disabled')) return;
const action = menuItem.dataset.action;
if (!action) return;

View File

@@ -24,6 +24,14 @@ export class LoraContextMenu extends BaseContextMenu {
showMenu(x, y, card) {
super.showMenu(x, y, card);
this.updateExcludeMenuItem();
this.updateEnrichMenuItem(card);
}
updateEnrichMenuItem(card) {
const enrichItem = this.menu?.querySelector('[data-action="enrich-hf-llm"]');
if (!enrichItem) return;
const hasHfUrl = !!card.dataset.hf_url;
enrichItem.classList.toggle('disabled', !hasHfUrl);
}
handleMenuAction(action, menuItem) {

View File

@@ -12,12 +12,12 @@
<div class="context-menu-item" data-action="check-updates">
<i class="fas fa-bell"></i> <span>{{ t('loras.contextMenu.checkUpdates') }}</span>
</div>
<div class="context-menu-item" data-action="enrich-hf-llm">
<i class="fas fa-wand-magic-sparkles"></i> <span>{{ t('loras.contextMenu.enrichHfAgent') }}</span>
</div>
<div class="context-menu-item" data-action="relink-civitai">
<i class="fas fa-link"></i> <span>{{ t('loras.contextMenu.relinkCivitai') }}</span>
</div>
<div class="context-menu-item" data-action="enrich-hf-llm">
<i class="fas fa-wand-magic-sparkles"></i> <span>{{ t('loras.contextMenu.enrichHfAgent') }}</span>
</div>
<div class="context-menu-separator menu-section-break"></div>
<!-- Workflow -->
<div class="context-menu-item" data-action="copyname">