From e639caa21dfa6b6646f1eae72f18a9115c03c408 Mon Sep 17 00:00:00 2001 From: TonyBlu Date: Mon, 25 May 2026 20:09:17 +0800 Subject: [PATCH] fix: Codex review P2 issues + frontend test failure - Reset download_phase when transitioning to paused (pause(), update_status(), _post_download_cleanup()) so UI shows 'Paused' instead of stale phase label - Reset download_phase when starting/resuming download (start() preparing state) - Count 'postprocessing' as active download in updateMetrics() so dashboard shows accurate counts during ffmpeg post-processing - Add missing completedDownload Subject to DownloadsServiceStub in app.spec.ts - Add Download type import to app.spec.ts Fixes: TypeError Cannot read properties of undefined (reading 'pipe') at app.ts:300 (completedDownload not in test stub) --- app/ytdl.py | 4 ++++ ui/src/app/app.spec.ts | 2 ++ ui/src/app/app.ts | 2 ++ 3 files changed, 8 insertions(+) diff --git a/app/ytdl.py b/app/ytdl.py index 6bfa2e7..4eb5526 100644 --- a/app/ytdl.py +++ b/app/ytdl.py @@ -647,6 +647,7 @@ class Download: self.loop = asyncio.get_running_loop() self.notifier = notifier self.info.status = 'preparing' + self.info.download_phase = None await self.notifier.updated(self.info) self.status_task = asyncio.create_task(self.update_status()) await self.loop.run_in_executor(None, self.proc.join) @@ -673,6 +674,7 @@ class Download: self.paused = True self.start_generation += 1 self.info.status = 'paused' + self.info.download_phase = None self.info.speed = None self.info.eta = None if self.running(): @@ -705,6 +707,7 @@ class Download: return if self.paused: self.info.status = 'paused' + self.info.download_phase = None self.info.speed = None self.info.eta = None await self.notifier.updated(self.info) @@ -988,6 +991,7 @@ class DownloadQueue: key = getattr(download.info, 'key', download.info.url) if download.paused: download.info.status = 'paused' + download.info.download_phase = None download.info.speed = None download.info.eta = None download.close() diff --git a/ui/src/app/app.spec.ts b/ui/src/app/app.spec.ts index cdaf356..1eb31a7 100644 --- a/ui/src/app/app.spec.ts +++ b/ui/src/app/app.spec.ts @@ -5,6 +5,7 @@ import { App } from './app'; import { DownloadsService } from './services/downloads.service'; import { SubscriptionsService } from './services/subscriptions.service'; import { CookieService } from 'ngx-cookie-service'; +import { Download } from './interfaces'; class DownloadsServiceStub { loading = false; @@ -18,6 +19,7 @@ class DownloadsServiceStub { customDirsChanged = new Subject>(); ytdlOptionsChanged = new Subject>(); updated = new Subject(); + completedDownload = new Subject(); getCookieStatus() { return of({ status: 'ok', has_cookies: false }); diff --git a/ui/src/app/app.ts b/ui/src/app/app.ts index 8422895..8c5398a 100644 --- a/ui/src/app/app.ts +++ b/ui/src/app/app.ts @@ -1651,6 +1651,8 @@ export class App implements AfterViewInit, OnInit, OnDestroy { speed += download.speed || 0; } else if (download.status === 'preparing') { active++; + } else if (download.status === 'postprocessing') { + active++; } else if (download.status === 'pending' || download.status === 'paused') { queued++; }