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 <noreply@anthropic.com>
This commit is contained in:
John Lightner 2026-04-01 00:44:18 -05:00
parent 57626f5f01
commit c8923f0142
2 changed files with 9 additions and 2 deletions

View file

@ -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.

View file

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