* feat: add Runpod serverless image collector pools * fix: prevent worker settings clipping and remove preview copy * fix: initialize worker settings before mounting the form * fix: validate complete serverless requests against 10 MB limit * fix: simplify serverless cards and keep status dots circular * fix: match serverless endpoint box to master card * fix: preserve serverless capacity and recovery across job failures Retain durable reservations until provider termination or explicit recovery, protect unresolved pools and credentials, and add scoped reconciliation. Consolidate lifecycle and secret policies and split prompt/media stages with regression coverage. * fix(serverless): disable Clear saved API key while the worker is enabled The checkbox read "Clear saved API key (disable pool first)", but the panel never defines "pool" and saving with it ticked on an enabled worker was rejected by the backend. - Disable the checkbox while the worker is enabled, with a tooltip saying to turn the worker off first. Also disable it when no key is saved. - Use "worker" instead of "pool" in user-facing serverless errors, the serverless guide and the README entry. * feat(serverless): replace Concurrent jobs with a single Images per run setting - Remove the separate Concurrent jobs field; rename Jobs per run to Images per run (1-16) with a tooltip explaining that Runpod's max workers decides how many GPUs run them. - Backend uses a fixed per-worker limit of 16 outstanding jobs, so all images of a run are submitted at once. Unresolved jobs still count against it. The limit is constant, so it never has to change while jobs are unresolved. - Legacy 'concurrency' in saved configs and older browser tabs is accepted and ignored/dropped; it no longer triggers the busy guard. - Revert the enable toggle and show the reason when the backend rejects it. - Trim a pasted api.runpod.ai/v2/<id> URL to the endpoint ID; plainer endpoint-ID error otherwise. - Confirm before a type change deletes a saved Runpod API key. - Update docs and tests.
133 lines
6.4 KiB
JavaScript
133 lines
6.4 KiB
JavaScript
import { STATUS_COLORS } from './constants.js';
|
|
import { checkAllWorkerStatuses, loadManagedWorkers, updateWorkerControls } from './workerLifecycle.js';
|
|
import { renderActionsSection } from './sidebar/actionsSection.js';
|
|
import { renderSettingsSection } from './sidebar/settingsSection.js';
|
|
import { renderWorkersSection } from './sidebar/workersSection.js';
|
|
|
|
export function updateWorkerCard(extension, workerId, newStatus = {}) {
|
|
const card = document.querySelector(`[data-worker-id="${workerId}"]`);
|
|
if (!card) {
|
|
return false;
|
|
}
|
|
|
|
const worker = extension.config?.workers?.find((w) => w.id === workerId);
|
|
if (!worker) {
|
|
return false;
|
|
}
|
|
|
|
const workerState = extension.state.getWorker(workerId);
|
|
const isLaunching = Boolean(workerState?.launching);
|
|
|
|
if (worker.type === "serverless") {
|
|
const providerStatus = workerState?.serverlessStatus || {};
|
|
if (newStatus.online && newStatus.processing) {
|
|
extension.ui.updateStatusDot(workerId, STATUS_COLORS.PROCESSING_YELLOW, `Runpod active (${newStatus.queueCount || 0} queued)`, false);
|
|
} else if (newStatus.online) {
|
|
extension.ui.updateStatusDot(workerId, STATUS_COLORS.ONLINE_GREEN, providerStatus.message || "Runpod ready to scale", false);
|
|
} else if (worker.enabled) {
|
|
extension.ui.updateStatusDot(workerId, STATUS_COLORS.OFFLINE_RED, providerStatus.message || "Runpod endpoint unavailable", false);
|
|
}
|
|
updateWorkerControls(extension, workerId);
|
|
return true;
|
|
}
|
|
|
|
if (isLaunching && !newStatus.online) {
|
|
extension.ui.updateStatusDot(workerId, STATUS_COLORS.PROCESSING_YELLOW, "Launching...", true);
|
|
} else if (newStatus.online && newStatus.processing) {
|
|
const queue = newStatus.queueCount || 0;
|
|
extension.ui.updateStatusDot(workerId, STATUS_COLORS.PROCESSING_YELLOW, `Online - Processing (${queue} in queue)`, false);
|
|
} else if (newStatus.online) {
|
|
extension.ui.updateStatusDot(workerId, STATUS_COLORS.ONLINE_GREEN, "Online - Idle", false);
|
|
} else if (worker.enabled) {
|
|
extension.ui.updateStatusDot(workerId, STATUS_COLORS.OFFLINE_RED, "Offline - Cannot connect", false);
|
|
}
|
|
|
|
updateWorkerControls(extension, workerId);
|
|
return true;
|
|
}
|
|
|
|
export async function renderSidebarContent(extension, el) {
|
|
// Panel is being opened/rendered
|
|
extension.log("Panel opened", "debug");
|
|
if (!el) {
|
|
extension.log("No element provided to renderSidebarContent", "debug");
|
|
return;
|
|
}
|
|
// Prevent infinite recursion
|
|
if (extension._isRendering) {
|
|
extension.log("Already rendering, skipping", "debug");
|
|
return;
|
|
}
|
|
extension._isRendering = true;
|
|
try {
|
|
// Store reference to the panel element
|
|
extension.panelElement = el;
|
|
// Show loading indicator
|
|
el.innerHTML = '';
|
|
const loadingDiv = document.createElement("div");
|
|
loadingDiv.style.cssText =
|
|
"display: flex; align-items: center; justify-content: center; height: calc(100vh - 100px); color: var(--dist-muted-text, #888);";
|
|
loadingDiv.innerHTML = `<svg width="24" height="24" viewBox="0 0 24 24" style="color: var(--dist-muted-text, #888);">
|
|
<circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-dasharray="40 40"/>
|
|
</svg>`;
|
|
el.appendChild(loadingDiv);
|
|
// Add rotation animation
|
|
const style = document.createElement('style');
|
|
style.textContent = `
|
|
@keyframes rotate {
|
|
from { transform: rotate(0deg); }
|
|
to { transform: rotate(360deg); }
|
|
}
|
|
`;
|
|
document.head.appendChild(style);
|
|
loadingDiv.querySelector('svg').style.animation = 'rotate 1s linear infinite';
|
|
// Preload data outside render
|
|
await Promise.all([extension.loadConfig(), loadManagedWorkers(extension), extension.refreshTunnelStatus()]);
|
|
extension.tunnelElements = {};
|
|
el.innerHTML = '';
|
|
// Create toolbar header to match ComfyUI style
|
|
const toolbar = document.createElement("div");
|
|
toolbar.className = "p-toolbar p-component border-x-0 border-t-0 rounded-none px-2 py-1 min-h-8";
|
|
toolbar.style.cssText =
|
|
"border-bottom: 1px solid var(--dist-divider, #444); background: transparent; display: flex; align-items: center;";
|
|
const toolbarStart = document.createElement("div");
|
|
toolbarStart.className = "p-toolbar-start";
|
|
toolbarStart.style.cssText = "display: flex; align-items: center;";
|
|
const titleSpan = document.createElement("span");
|
|
titleSpan.className = "text-xs 2xl:text-sm truncate";
|
|
titleSpan.textContent = "COMFYUI DISTRIBUTED";
|
|
titleSpan.title = "ComfyUI Distributed";
|
|
toolbarStart.appendChild(titleSpan);
|
|
toolbar.appendChild(toolbarStart);
|
|
const toolbarCenter = document.createElement("div");
|
|
toolbarCenter.className = "p-toolbar-center";
|
|
toolbar.appendChild(toolbarCenter);
|
|
const toolbarEnd = document.createElement("div");
|
|
toolbarEnd.className = "p-toolbar-end";
|
|
toolbar.appendChild(toolbarEnd);
|
|
el.appendChild(toolbar);
|
|
// Main container with adjusted padding
|
|
const container = document.createElement("div");
|
|
container.style.cssText = "padding: 15px; display: flex; flex-direction: column; height: calc(100% - 32px);";
|
|
// Detect master info on panel open (in case CUDA info wasn't available at startup)
|
|
extension.log(`Panel opened. CUDA device count: ${extension.cudaDeviceCount}, Workers: ${extension.config?.workers?.length || 0}`, "debug");
|
|
if (!extension.cudaDeviceCount) {
|
|
await extension.detectMasterIP();
|
|
}
|
|
// Now render with guaranteed up-to-date config
|
|
// Master Node Section
|
|
const masterDiv = extension.ui.renderEntityCard('master', extension.config?.master, extension);
|
|
container.appendChild(masterDiv);
|
|
container.appendChild(renderWorkersSection(extension));
|
|
container.appendChild(renderActionsSection(extension));
|
|
container.appendChild(renderSettingsSection(extension));
|
|
el.appendChild(container);
|
|
extension._applyThemeToneClass?.();
|
|
// Start checking worker statuses immediately in parallel
|
|
setTimeout(() => checkAllWorkerStatuses(extension), 0);
|
|
} finally {
|
|
// Always reset the rendering flag
|
|
extension._isRendering = false;
|
|
}
|
|
}
|