mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-07-07 01:41:17 -03:00
feat(agent): enrich_hf_metadata with per-model progress and in-place card update
- PostProcessor returns updates dict from enrich_hf_metadata - AgentService includes updated_data per model in WebSocket progress events - Convert preview_url to HTTP URL via config.get_preview_static_url() - LoraContextMenu: showEnhancedProgress + updateSingleItem per model - BulkContextMenu: same pattern, remove window.location.reload() - Guard empty updated_data and clean up callbacks on HTTP error
This commit is contained in:
@@ -377,7 +377,6 @@ export class BulkContextMenu extends BaseContextMenu {
|
||||
|
||||
const { agentManager } = await import('../../managers/AgentManager.js');
|
||||
|
||||
// Check if LLM is configured
|
||||
const configured = await agentManager.isLlmConfigured();
|
||||
if (!configured) {
|
||||
showToast('toast.agent.llmNotConfigured', {}, 'warning');
|
||||
@@ -386,23 +385,39 @@ export class BulkContextMenu extends BaseContextMenu {
|
||||
|
||||
const modelPaths = [...state.selectedModels];
|
||||
|
||||
// Connect WebSocket for progress
|
||||
agentManager.connect();
|
||||
|
||||
// Set up one-time completion handler
|
||||
const progressUI = state.loadingManager.showEnhancedProgress(
|
||||
`Enriching metadata for ${modelPaths.length} models...`
|
||||
);
|
||||
|
||||
const onProgress = (data) => {
|
||||
if (data.status === 'processing' && data.current_path && data.updated_data && Object.keys(data.updated_data).length > 0) {
|
||||
if (state.virtualScroller?.updateSingleItem) {
|
||||
state.virtualScroller.updateSingleItem(data.current_path, data.updated_data);
|
||||
}
|
||||
const pct = data.total > 0 ? Math.floor((data.processed / data.total) * 100) : 0;
|
||||
const name = data.current_path.split('/').pop();
|
||||
progressUI.updateProgress(pct, name, `Processing ${data.processed}/${data.total}: ${name}`);
|
||||
}
|
||||
};
|
||||
agentManager.onProgress(onProgress);
|
||||
|
||||
const onComplete = (data) => {
|
||||
const idx = agentManager.completeCallbacks.indexOf(onComplete);
|
||||
if (idx >= 0) agentManager.completeCallbacks.splice(idx, 1);
|
||||
const pIdx = agentManager.progressCallbacks.indexOf(onProgress);
|
||||
if (pIdx >= 0) agentManager.progressCallbacks.splice(pIdx, 1);
|
||||
const cIdx = agentManager.completeCallbacks.indexOf(onComplete);
|
||||
if (cIdx >= 0) agentManager.completeCallbacks.splice(cIdx, 1);
|
||||
|
||||
if (data.status === 'completed') {
|
||||
progressUI.complete(data.summary || 'Enrich complete');
|
||||
showToast(
|
||||
'toast.agent.enrichComplete',
|
||||
{ summary: data.summary || 'Done' },
|
||||
'success'
|
||||
);
|
||||
// Soft reload to reflect updated metadata
|
||||
window.location.reload();
|
||||
} else if (data.status === 'error') {
|
||||
state.loadingManager.hide();
|
||||
showToast(
|
||||
'toast.agent.enrichFailed',
|
||||
{ error: data.error || 'Unknown error' },
|
||||
@@ -412,15 +427,14 @@ export class BulkContextMenu extends BaseContextMenu {
|
||||
};
|
||||
agentManager.onComplete(onComplete);
|
||||
|
||||
showToast(
|
||||
'toast.agent.enrichStarted',
|
||||
{ count: modelPaths.length },
|
||||
'info'
|
||||
);
|
||||
|
||||
try {
|
||||
await agentManager.executeSkill('enrich_hf_metadata', modelPaths);
|
||||
} catch (error) {
|
||||
const pIdx = agentManager.progressCallbacks.indexOf(onProgress);
|
||||
if (pIdx >= 0) agentManager.progressCallbacks.splice(pIdx, 1);
|
||||
const cIdx = agentManager.completeCallbacks.indexOf(onComplete);
|
||||
if (cIdx >= 0) agentManager.completeCallbacks.splice(cIdx, 1);
|
||||
state.loadingManager.hide();
|
||||
showToast(
|
||||
'toast.agent.enrichFailed',
|
||||
{ error: error.message },
|
||||
|
||||
Reference in New Issue
Block a user