Add a Workflows page that manages ComfyUI workflow JSON files as a first-class library alongside loras/checkpoints/embeddings: - opt-in via the new 'Workflow Management' settings toggle (default off) - dedicated workflow folder roots with sidecar/preview support, separate from ComfyUI's own workflow storage; 'Send to ComfyUI' loads a workflow straight into the graph - workflow scanner parses the graph document (UI/API format sniffing, node classes, model/civitai refs) and persists the analysis in the SQLite model cache - settings UI: workflow folder paths editor in the Library tab and the standalone Model Paths page Fixes from sandbox E2E verification: - include the workflow scanner in startup initialization so the page no longer hangs on 'initializing' when enabled without folders - add the missing workflows entry to the frontend page-state map (page init crashed and the sidebar fell back to the loras tree without it) - project workflow analysis fields through the scanner cache entry and persist them in the model cache (new columns with auto-migration) - keep symlinked paths intact in the directory picker (abspath instead of resolve), so stored library paths match what the user sees on disk Also rebuilds the vue-widgets bundle to sync it with web/comfyui/utils.js.
68 lines
2.3 KiB
JavaScript
68 lines
2.3 KiB
JavaScript
/**
|
|
* Shared helpers for the opt-in Workflow management feature.
|
|
*
|
|
* Used by the disabled page so that enabling the feature goes through the same
|
|
* settings API call as the Settings modal toggle.
|
|
*/
|
|
|
|
/**
|
|
* Turn on Workflow management and reload so the server-rendered nav and the
|
|
* scanner state pick up the change.
|
|
*/
|
|
export async function enableWorkflows() {
|
|
const response = await fetch('/api/lm/settings', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ enable_workflows: true }),
|
|
});
|
|
const data = await response.json().catch(() => ({}));
|
|
if (!response.ok || data.success === false) {
|
|
throw new Error(data.error || `HTTP ${response.status}`);
|
|
}
|
|
window.location.reload();
|
|
}
|
|
|
|
/**
|
|
* Open the settings modal on the Library section and scroll the Workflows
|
|
* toggle into view.
|
|
*/
|
|
export function openWorkflowsSettings() {
|
|
const modalManager = window.modalManager;
|
|
if (modalManager && typeof modalManager.showModal === 'function') {
|
|
modalManager.showModal('settingsModal');
|
|
}
|
|
|
|
window.setTimeout(() => {
|
|
document.querySelectorAll('.settings-section').forEach((section) => {
|
|
section.classList.remove('active');
|
|
});
|
|
document.getElementById('section-library')?.classList.add('active');
|
|
|
|
document.querySelectorAll('.settings-nav-item').forEach((item) => {
|
|
item.classList.remove('active');
|
|
});
|
|
document.querySelector('.settings-nav-item[data-section="library"]')?.classList.add('active');
|
|
|
|
document.getElementById('enableWorkflows')?.scrollIntoView({
|
|
behavior: 'smooth',
|
|
block: 'center',
|
|
});
|
|
}, 100);
|
|
}
|
|
|
|
/**
|
|
* Open the settings modal on the standalone-only Model Paths section, where
|
|
* primary folder_paths are edited. The section only exists in standalone mode,
|
|
* so the nav item lookup simply no-ops elsewhere.
|
|
*/
|
|
export function openModelPathsSettings() {
|
|
const modalManager = window.modalManager;
|
|
if (modalManager && typeof modalManager.showModal === 'function') {
|
|
modalManager.showModal('settingsModal');
|
|
}
|
|
|
|
window.setTimeout(() => {
|
|
document.querySelector('.settings-nav-item[data-section="modelPaths"]')?.click();
|
|
}, 100);
|
|
}
|