diff --git a/src/renderer/src/components/downloadBar/useDownloadBar.ts b/src/renderer/src/components/downloadBar/useDownloadBar.ts index 8ac30cc..e6ec2f4 100644 --- a/src/renderer/src/components/downloadBar/useDownloadBar.ts +++ b/src/renderer/src/components/downloadBar/useDownloadBar.ts @@ -281,11 +281,11 @@ export function useDownloadBar(): DownloadBarController { playlist === null && probeError === null - function clearProbe(): void { - setInfo(null) - setProbeError(null) - setFormatId('') - setPlaylist(null) + // Per-entry format state is keyed by playlist position, so it must be dropped + // any time the playlist itself is dropped or re-fetched -- otherwise a stale + // exact-format pick from a prior probe can silently reattach to a different + // video that lands at the same index in the new result. + function resetPlaylistItemState(): void { setSelected(new Set()) setItemKinds({}) setFormatExpanded(new Set()) @@ -295,6 +295,14 @@ export function useDownloadBar(): DownloadBarController { setFormatProbeError({}) } + function clearProbe(): void { + setInfo(null) + setProbeError(null) + setFormatId('') + setPlaylist(null) + resetPlaylistItemState() + } + // Reset the whole bar after a download / playlist is enqueued: clear the URL + // probe and drop the one-shot overrides (trim / schedule / advanced / incognito / // per-download options) so the next download starts from the global defaults. @@ -387,6 +395,7 @@ export function useDownloadBar(): DownloadBarController { setProbeError(null) setInfo(null) setPlaylist(null) + resetPlaylistItemState() // Probing may switch the URL to the format-picker path, changing the command. setCommandPreview(null) try {