From 660221d86a1a638abb277a262fe455b80097f5ed Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Wed, 1 Apr 2026 09:05:33 -0700 Subject: [PATCH] Show 'Yielding for downloads' on auto-paused enrichment workers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dashboard enrichment chips show 'Yielding' instead of 'Paused' when workers are auto-paused during downloads. Tooltips show 'Yielding for downloads' for full context. Distinguishes user-paused from auto-paused. Also handles edge case where user manually resumes a worker during downloads — adds to override set so the loop doesn't re-pause it. Override resets when downloads finish so next download session re-pauses. --- web_server.py | 14 +++++++++++++- webui/static/script.js | 12 ++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/web_server.py b/web_server.py index 76fb0044..3459b065 100644 --- a/web_server.py +++ b/web_server.py @@ -44529,6 +44529,8 @@ def spotify_enrichment_resume(): spotify_enrichment_worker.resume() config_manager.set('spotify_enrichment_paused', False) + _download_auto_paused.discard('spotify-enrichment') + _download_yield_override.add('spotify-enrichment') # User override — don't re-pause during this download session logger.info("Spotify enrichment worker resumed via UI") return jsonify({'status': 'running'}), 200 except Exception as e: @@ -44682,6 +44684,8 @@ def lastfm_enrichment_resume(): lastfm_worker.resume() config_manager.set('lastfm_enrichment_paused', False) + _download_auto_paused.discard('lastfm-enrichment') + _download_yield_override.add('lastfm-enrichment') # User override — don't re-pause during this download session logger.info("Last.fm worker resumed via UI") return jsonify({'status': 'running'}), 200 except Exception as e: @@ -44823,6 +44827,8 @@ def genius_enrichment_resume(): genius_worker.resume() config_manager.set('genius_enrichment_paused', False) + _download_auto_paused.discard('genius-enrichment') + _download_yield_override.add('genius-enrichment') # User override — don't re-pause during this download session logger.info("Genius worker resumed via UI") return jsonify({'status': 'running'}), 200 except Exception as e: @@ -47037,6 +47043,7 @@ def _has_active_downloads(): # Track whether we auto-paused workers so we only resume ones we paused (not user-paused ones) _download_auto_paused = set() +_download_yield_override = set() # Workers the user explicitly resumed during downloads — don't re-pause def _emit_enrichment_status_loop(): @@ -47071,11 +47078,13 @@ def _emit_enrichment_status_loop(): # Auto-pause/resume rate-limited workers during downloads try: downloading = _has_active_downloads() + if not downloading: + _download_yield_override.clear() # Reset overrides when downloads finish for name, get_w in yield_workers.items(): w = get_w() if w is None: continue - if downloading and not w.paused: + if downloading and not w.paused and name not in _download_yield_override: w.paused = True _download_auto_paused.add(name) logger.debug(f"Auto-paused {name} during active downloads") @@ -47092,6 +47101,9 @@ def _emit_enrichment_status_loop(): if worker is None: continue status = worker.get_stats() + # Flag workers that were auto-paused for downloads + if name in _download_auto_paused: + status['yield_reason'] = 'downloads' socketio.emit(f'enrichment:{name}', status) except Exception as e: logger.debug(f"Error emitting {name} status: {e}") diff --git a/webui/static/script.js b/webui/static/script.js index 9d007700..7f109888 100644 --- a/webui/static/script.js +++ b/webui/static/script.js @@ -36316,7 +36316,7 @@ function renderEnrichmentCards(enrichment) { statusLabel = 'Set up'; } else if (svc.paused) { statusClass = 'paused'; - statusLabel = 'Paused'; + statusLabel = svc.yield_reason === 'downloads' ? 'Yielding' : 'Paused'; } else if (svc.running) { statusClass = svc.idle ? 'idle' : 'running'; statusLabel = svc.idle ? 'Idle' : 'Running'; @@ -53937,7 +53937,7 @@ function updateMusicBrainzStatusFromData(data) { } else if (data.running && !data.paused) { tooltipStatus.textContent = 'Running'; } else if (data.paused) { - tooltipStatus.textContent = 'Paused'; + tooltipStatus.textContent = data.yield_reason === 'downloads' ? 'Yielding for downloads' : 'Paused'; } else { tooltipStatus.textContent = 'Idle'; } @@ -54070,7 +54070,7 @@ function updateAudioDBStatusFromData(data) { if (tooltipStatus) { if (data.idle) { tooltipStatus.textContent = 'Complete'; } else if (data.running && !data.paused) { tooltipStatus.textContent = 'Running'; } - else if (data.paused) { tooltipStatus.textContent = 'Paused'; } + else if (data.paused) { tooltipStatus.textContent = data.yield_reason === 'downloads' ? 'Yielding for downloads' : 'Paused'; } else { tooltipStatus.textContent = 'Idle'; } } @@ -54196,7 +54196,7 @@ function updateDeezerStatusFromData(data) { if (tooltipStatus) { if (data.idle) { tooltipStatus.textContent = 'Complete'; } else if (data.running && !data.paused) { tooltipStatus.textContent = 'Running'; } - else if (data.paused) { tooltipStatus.textContent = 'Paused'; } + else if (data.paused) { tooltipStatus.textContent = data.yield_reason === 'downloads' ? 'Yielding for downloads' : 'Paused'; } else { tooltipStatus.textContent = 'Idle'; } } @@ -54469,7 +54469,7 @@ function updateiTunesEnrichmentStatusFromData(data) { if (tooltipStatus) { if (data.idle) { tooltipStatus.textContent = 'Complete'; } else if (data.running && !data.paused) { tooltipStatus.textContent = 'Running'; } - else if (data.paused) { tooltipStatus.textContent = 'Paused'; } + else if (data.paused) { tooltipStatus.textContent = data.yield_reason === 'downloads' ? 'Yielding for downloads' : 'Paused'; } else { tooltipStatus.textContent = 'Idle'; } } @@ -55161,7 +55161,7 @@ function updateRepairStatusFromData(data) { if (tooltipStatus) { if (data.idle) { tooltipStatus.textContent = 'Complete'; } else if (data.running && !data.paused) { tooltipStatus.textContent = 'Running'; } - else if (data.paused) { tooltipStatus.textContent = 'Paused'; } + else if (data.paused) { tooltipStatus.textContent = data.yield_reason === 'downloads' ? 'Yielding for downloads' : 'Paused'; } else { tooltipStatus.textContent = 'Idle'; } }