From c8923f014201635345c9d4b7de3a938162094ee5 Mon Sep 17 00:00:00 2001 From: John Lightner Date: Wed, 1 Apr 2026 00:44:18 -0500 Subject: [PATCH] MAESTRO: Add activity, channels, and library query invalidation on WebSocket download events When a download completes or fails, the UI now immediately refreshes the Activity page, channel content counts, and Library page in addition to the existing content and queue invalidations. Co-Authored-By: Claude Opus 4.6 --- .../WEBSOCKET-PROGRESS-01.md | 3 ++- src/frontend/src/contexts/DownloadProgressContext.tsx | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Auto Run Docs/Initiation/2026-03-31-WebSocket-Progress-And-Polish/WEBSOCKET-PROGRESS-01.md b/Auto Run Docs/Initiation/2026-03-31-WebSocket-Progress-And-Polish/WEBSOCKET-PROGRESS-01.md index 4453db7..915e42c 100644 --- a/Auto Run Docs/Initiation/2026-03-31-WebSocket-Progress-And-Polish/WEBSOCKET-PROGRESS-01.md +++ b/Auto Run Docs/Initiation/2026-03-31-WebSocket-Progress-And-Polish/WEBSOCKET-PROGRESS-01.md @@ -40,8 +40,9 @@ The backend event bus, WebSocket route, progress parser, and frontend context/ho - Verify the `--newline` and `--progress` flags are added to yt-dlp args in `spawnDownload` (they should already be there) - **Verified:** All wiring is correct. Single `DownloadEventBus` instance created in `src/index.ts:61` is shared between `buildServer` (→ WebSocket route) and `DownloadService`. `spawnDownload` adds `--newline`/`--progress` flags, parses progress lines, and emits all three event types. WebSocket route subscribes and broadcasts to clients. All 13 related tests pass. -- [ ] Invalidate relevant queries on WebSocket events for immediate UI freshness: +- [x] Invalidate relevant queries on WebSocket events for immediate UI freshness: - Read the `DownloadProgressContext.tsx` — it already invalidates `content` and `queue` query keys on `download:complete` and `download:failed` - Read `src/frontend/src/api/hooks/useQueue.ts` and `src/frontend/src/api/hooks/useContent.ts` to verify they use matching query keys - Also invalidate `activity` and `channels` query keys on complete/failed events so the Activity page and channel content counts update without manual refresh - Add `library` query key invalidation on complete events if the library hook uses a separate query key + - **Done:** Added `activity`, `channels`, and `library` query key invalidations to both `download:complete` and `download:failed` handlers in `DownloadProgressContext.tsx`. Verified query keys match: `useActivity` uses `['activity']`, `useChannels` uses `['channels']`, `useLibraryContent` uses `['library']`. Frontend builds clean, all 40 backend tests pass. diff --git a/src/frontend/src/contexts/DownloadProgressContext.tsx b/src/frontend/src/contexts/DownloadProgressContext.tsx index 5683b66..a6960a1 100644 --- a/src/frontend/src/contexts/DownloadProgressContext.tsx +++ b/src/frontend/src/contexts/DownloadProgressContext.tsx @@ -100,9 +100,12 @@ export function DownloadProgressProvider({ children }: { children: ReactNode }) case 'download:complete': store.delete(event.contentItemId); - // Invalidate content queries so the UI refreshes with updated status + // Invalidate queries so the UI refreshes with updated status queryClient.invalidateQueries({ queryKey: ['content'] }); queryClient.invalidateQueries({ queryKey: ['queue'] }); + queryClient.invalidateQueries({ queryKey: ['activity'] }); + queryClient.invalidateQueries({ queryKey: ['channels'] }); + queryClient.invalidateQueries({ queryKey: ['library'] }); break; case 'download:failed': @@ -110,6 +113,9 @@ export function DownloadProgressProvider({ children }: { children: ReactNode }) // Invalidate to show updated status (failed) queryClient.invalidateQueries({ queryKey: ['content'] }); queryClient.invalidateQueries({ queryKey: ['queue'] }); + queryClient.invalidateQueries({ queryKey: ['activity'] }); + queryClient.invalidateQueries({ queryKey: ['channels'] }); + queryClient.invalidateQueries({ queryKey: ['library'] }); break; } },