Merge pull request #4936 from Artheriax/dev

User option to enable/disable out-of-focus live previews
This commit is contained in:
Vladimir Mandic
2026-06-20 08:09:50 +02:00
committed by GitHub
2 changed files with 3 additions and 2 deletions
+1
View File
@@ -570,6 +570,7 @@ def create_settings(cmd_opts):
"live_preview_refresh_period": OptionInfo(500, "Progress update period", gr.Slider, {"minimum": 0, "maximum": 5000, "step": 25}),
"taesd_variant": OptionInfo(shared_items.sd_taesd_items()[0], "TAESD variant", gr.Dropdown, {"choices": shared_items.sd_taesd_items()}),
"taesd_layers": OptionInfo(3, "TAESD decode layers", gr.Slider, {"minimum": 1, "maximum": 3, "step": 1}),
"live_preview_require_focus": OptionInfo(True, "Pause live previews when tab is not focused"),
"live_preview_downscale": OptionInfo(True, "Downscale high resolution live previews"),
"notification_audio_enable": OptionInfo(False, "Play a notification upon completion"),
+2 -2
View File
@@ -11,7 +11,7 @@ export function setRefreshInterval() {
refreshInterval = window.opts.live_preview_refresh_period || 500;
log('refreshInterval', document.visibilityState, refreshInterval);
document.addEventListener('visibilitychange', () => {
if (document.hidden) refreshInterval = Math.max(2500, window.opts.live_preview_refresh_period || 1000);
if (window.opts.live_preview_require_focus !== false && document.hidden) refreshInterval = Math.max(2500, window.opts.live_preview_refresh_period || 1000);
else refreshInterval = window.opts.live_preview_refresh_period || 1000;
// log('refreshInterval', document.visibilityState, refreshInterval);
});
@@ -148,7 +148,7 @@ export function requestProgress(id_task = 'undefined', progressEl = null, galler
const startLivePreview = (taskId: string, id_live_preview: number) => {
if (window.opts.live_preview_refresh_period === 0) return;
const request_id = document.hidden ? -1 : id_live_preview;
const request_id = (window.opts.live_preview_require_focus !== false && document.hidden) ? -1 : id_live_preview;
const onProgressHandler = (res) => {
if (res?.debug) debug('progress:', { start: dateStart, id: request_id, res });