diff --git a/web/executionUtils.js b/web/executionUtils.js index f7a40f6..bbf700b 100644 --- a/web/executionUtils.js +++ b/web/executionUtils.js @@ -45,7 +45,9 @@ export function setupInterceptor(extension) { if (hasCollector || hasDistUpscale) { const result = await executeParallelDistributed(extension, prompt); - // Check status after dispatching jobs + // Immediate status check for instant feedback + extension.checkAllWorkerStatuses(); + // Another check after a short delay to catch state changes setTimeout(() => extension.checkAllWorkerStatuses(), TIMEOUTS.POST_ACTION_DELAY); return result; } @@ -298,6 +300,10 @@ export async function executeJobs(extension, jobs) { } }); await Promise.all(promises); + + // Trigger immediate status check for instant feedback + extension.checkAllWorkerStatuses(); + return masterPromptId || { "prompt_id": "distributed-job-dispatched" }; } diff --git a/web/main.js b/web/main.js index 7a5be5d..f59ce4e 100644 --- a/web/main.js +++ b/web/main.js @@ -26,6 +26,9 @@ class DistributedExtension { // Initialize API client this.api = createApiClient(window.location.origin); + + // Initialize status check timeout reference + this.statusCheckTimeout = null; // Inject CSS for pulsing animation this.injectStyles(); @@ -206,9 +209,7 @@ class DistributedExtension { } startStatusChecking() { - this.statusCheckInterval = setInterval(() => { - this.checkAllWorkerStatuses(); - }, TIMEOUTS.STATUS_CHECK); + this.checkAllWorkerStatuses(); } async checkAllWorkerStatuses() { @@ -223,6 +224,23 @@ class DistributedExtension { this.checkWorkerStatus(worker); } } + + // Determine next interval based on current state + let isActive = this.state.getMasterStatus() === 'processing'; // Master is busy + + // Check workers for activity + this.config.workers.forEach(worker => { + const ws = this.state.getWorker(worker.id); // Get worker state + if (ws.launching || ws.status?.processing) { // Launching or processing + isActive = true; + } + }); + + // Set next delay: 1s if active, 5s if idle + const nextInterval = isActive ? 1000 : 5000; + + // Schedule the next check + this.statusCheckTimeout = setTimeout(() => this.checkAllWorkerStatuses(), nextInterval); } async checkMasterStatus() { @@ -545,6 +563,11 @@ class DistributedExtension { this.logAutoRefreshInterval = null; } + if (this.statusCheckTimeout) { + clearTimeout(this.statusCheckTimeout); + this.statusCheckTimeout = null; + } + this.log("Cleaned up intervals", "debug"); }