From 00decaaa204bde01365d6175de6dbe1656b705f5 Mon Sep 17 00:00:00 2001 From: awsr <43862868+awsr@users.noreply.github.com> Date: Sun, 14 Dec 2025 01:27:30 -0800 Subject: [PATCH] Fix generation loop state check This also fixes log spam in the Python console. --- javascript/contextMenus.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/javascript/contextMenus.js b/javascript/contextMenus.js index 26d10d522..7e6576d0e 100644 --- a/javascript/contextMenus.js +++ b/javascript/contextMenus.js @@ -100,13 +100,20 @@ const generateForever = (genbuttonid) => { clearInterval(window.generateOnRepeatInterval); window.generateOnRepeatInterval = null; } else { - log('generateForever: start'); const genbutton = gradioApp().querySelector(genbuttonid); - const busy = document.getElementById('progressbar')?.style.display === 'block'; - if (!busy) genbutton.click(); + const isBusy = () => { + let busy = document.getElementById('progressbar')?.style.display === 'block'; + if (!busy) { + // Also check in Modern UI + const outerButton = genbutton.parentElement.closest('button'); + busy = outerButton?.classList.contains('generate') && outerButton?.classList.contains('active'); + } + return busy; + } + log('generateForever: start'); + if (!isBusy()) genbutton.click(); window.generateOnRepeatInterval = setInterval(() => { - const pbBusy = document.getElementById('progressbar')?.style.display === 'block'; - if (!pbBusy) genbutton.click(); + if (!isBusy()) genbutton.click(); }, 500); } };