- Replace the multi-root folder_paths.workflows workflow library with a scalar workflow_path setting (Settings > Library); remove the extra_folder_paths.workflows path and the standalone Model Paths editor. - Migrate pre-release settings.json files that still keep folder_paths.workflows / extra_folder_paths.workflows on startup, so an upgrade keeps the configured folder instead of silently losing it. - Add "Create LM-managed workflow" to the ComfyUI Graph menu and the File menu/command palette: it writes the serialized graph into the configured folder, stamps extra.lm_source and registers the entry in the scanner cache without forcing a rescan. - Attach the decode image of the client's last executed prompt as the workflow preview. The prompt id is sent with the create request and the backend only honors it while it is still the registry's current prompt, so a tab never borrows another tab's output; otherwise the card keeps the placeholder preview. - Detect library entries deleted/renamed while a graph still carries the marker: a link-status endpoint clears the stale extra.lm_source (on graph load, menu open and before create/update), and the write-back route returns 404 instead of recreating the document. - Collapse the workflows.noPaths standalone/ComfyUI split into a single description/hint; the folder is edited in Settings > Library in both modes, so the manual settings.json guidance and the standalone open-settings-folder fallback are gone. - Add the preview tensor conversion as a shared utility (reused by the recipe widget save path) and cover create, preview gating, link status, migration and menu injection with tests.
58 lines
2.0 KiB
JavaScript
58 lines
2.0 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 to the workflow
|
|
* folder input (the empty state only appears when the feature is on), falling
|
|
* back to the enable toggle while the input is hidden.
|
|
*/
|
|
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');
|
|
|
|
const pathInput = document.getElementById('workflowPath');
|
|
const target =
|
|
pathInput && pathInput.offsetParent !== null
|
|
? pathInput
|
|
: document.getElementById('enableWorkflows');
|
|
target?.scrollIntoView({
|
|
behavior: 'smooth',
|
|
block: 'center',
|
|
});
|
|
}, 100);
|
|
}
|