Files
willmiao-ComfyUI-Lora-Manager/static/js/workflows_disabled.js
T
Will Miao 874d0e96d8 feat(workflows): single library folder + create from ComfyUI
- 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.
2026-10-30 17:35:53 +08:00

54 lines
1.8 KiB
JavaScript

import { appCore } from './core.js';
import { showToast } from './utils/uiHelpers.js';
import { enableWorkflows, openWorkflowsSettings } from './utils/workflowModels.js';
/**
* Workflow management is an opt-in feature. While it is disabled this page
* renders an empty state whose button turns the feature on; the backend then
* rebuilds the workflow root and starts scanning, so a reload lands on the
* real page.
*
* The same module backs the "enabled but no folder configured" state: both
* modes point at Settings > Library (the single workflow_path input).
*/
async function handleEnableClick() {
const button = document.getElementById('enableWorkflowsBtn');
if (!button || button.disabled) return;
button.disabled = true;
try {
await enableWorkflows();
} catch (error) {
button.disabled = false;
showToast('workflows.disabled.enableFailed', { message: error.message }, 'error');
}
}
/**
* Open Settings on the Library section for the "no folder configured" state.
*/
function handleOpenSettingsClick(event) {
event.preventDefault();
openWorkflowsSettings();
}
async function initializeWorkflowsDisabledPage() {
// appCore.initialize() wires the shared header (theme, settings modal,
// language) so this page is not a dead end.
await appCore.initialize();
const button = document.getElementById('enableWorkflowsBtn');
if (button) {
button.addEventListener('click', handleEnableClick);
}
const settingsButton = document.getElementById('openWorkflowsSettingsBtn');
if (settingsButton) {
settingsButton.addEventListener('click', handleOpenSettingsClick);
}
}
document.addEventListener('DOMContentLoaded', initializeWorkflowsDisabledPage);
export { handleEnableClick as enableWorkflows, initializeWorkflowsDisabledPage };