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; } },