Enhance model download handling in useGenerationForm and ProgressManager

- Introduced a flag to track download status in useGenerationForm, ensuring proper UI updates during model downloads.
- Updated ProgressManager to only send initial progress updates if the model is actively downloading or extracting, preventing outdated status messages from being sent.
- Improved error handling and logging for better visibility into model download processes.
This commit is contained in:
Jamie Pine
2026-01-29 15:57:53 -08:00
parent 3be8980f48
commit cf3cf3f002
2 changed files with 18 additions and 5 deletions
+9 -3
View File
@@ -121,10 +121,16 @@ class ProgressManager:
logger.info(f"SSE client subscribed to {model_name}, total listeners: {len(self._listeners[model_name])}")
try:
# Send initial progress if available
# Send initial progress if available and still in progress
if model_name in self._progress:
logger.info(f"Sending initial progress for {model_name}: {self._progress[model_name].get('status')}")
yield f"data: {json.dumps(self._progress[model_name])}\n\n"
status = self._progress[model_name].get('status')
# Only send initial progress if download is actually in progress
# Don't send old 'complete' or 'error' status from previous downloads
if status in ('downloading', 'extracting'):
logger.info(f"Sending initial progress for {model_name}: {status}")
yield f"data: {json.dumps(self._progress[model_name])}\n\n"
else:
logger.info(f"Skipping initial progress for {model_name} (status: {status})")
else:
logger.info(f"No initial progress available for {model_name}")