diff --git a/src/renderer/src/components/DownloadBar.tsx b/src/renderer/src/components/DownloadBar.tsx index a98a070..8893f14 100644 --- a/src/renderer/src/components/DownloadBar.tsx +++ b/src/renderer/src/components/DownloadBar.tsx @@ -264,12 +264,20 @@ const useStyles = makeStyles({ backgroundColor: tokens.colorNeutralBackground2, ...shorthands.borderRadius(tokens.borderRadiusLarge), border: `1px solid ${tokens.colorNeutralStroke2}`, - fontFamily: 'monospace', + fontFamily: tokens.fontFamilyMonospace, fontSize: tokens.fontSizeBase200, overflowX: 'auto', + whiteSpace: 'pre-wrap', + wordBreak: 'break-all', color: tokens.colorNeutralForeground1 }, + commandError: { + color: tokens.colorStatusDangerForeground1 + }, optionsPanel: { + display: 'flex', + flexDirection: 'column', + gap: '12px', padding: '12px', backgroundColor: tokens.colorNeutralBackground2, ...shorthands.borderRadius(tokens.borderRadiusLarge), @@ -403,20 +411,28 @@ export function DownloadBar(): React.JSX.Element { setItemKinds({}) } - async function loadCommandPreview(): Promise { - const trimmed = url.trim() - if (!trimmed) { + // Fetch (or toggle off) the exact yt-dlp command line for the current form + // state. The options mirror what download() sends so the preview matches the + // command that will actually run -- including a probe-selected format and any + // trim spec (M5). + async function toggleCommandPreview(): Promise { + if (commandPreview) { setCommandPreview(null) return } + const trimmed = url.trim() + if (!trimmed) return setPreviewLoading(true) try { const result = await window.api.previewCommand({ id: 'preview', url: trimmed, - kind, - quality, - options: downloadOptions + kind: usingFormats ? 'video' : kind, + quality: usingFormats && selectedFormat ? selectedFormat.label : quality, + formatId: usingFormats ? selectedFormat?.id : undefined, + formatHasAudio: usingFormats ? selectedFormat?.hasAudio : undefined, + options: downloadOptions, + trim: trim.trim() || undefined }) setCommandPreview(result) } catch (e) { @@ -431,13 +447,15 @@ export function DownloadBar(): React.JSX.Element { // Any probed info -- or a duplicate warning -- is stale once the URL changes. if (info || probeError || playlist) clearProbe() if (dup) setDup(null) - if (commandPreview) setCommandPreview(null) + setCommandPreview(null) confirmDup.current = false } function onKindChange(next: MediaKind): void { setKind(next) setQuality(QUALITY_OPTIONS[next][0]) + // The command changes with kind/quality, so any shown preview is now stale. + setCommandPreview(null) } async function fetchFormats(): Promise { @@ -447,6 +465,8 @@ export function DownloadBar(): React.JSX.Element { setProbeError(null) setInfo(null) setPlaylist(null) + // Probing may switch the URL to the format-picker path, changing the command. + setCommandPreview(null) try { const res = await window.api.probe(trimmed) if (res.ok && res.kind === 'playlist' && res.playlist) { @@ -573,6 +593,11 @@ export function DownloadBar(): React.JSX.Element { setShowSchedule(false) setShowAdvanced(false) setCommandPreview(null) + // Per-download overrides are one-shot (like trim/schedule): reset so the next + // download starts from the global defaults, and incognito never silently + // carries over to a following download. + setIncognito(false) + setDownloadOptions(DEFAULT_DOWNLOAD_OPTIONS) clearProbe() } @@ -814,7 +839,10 @@ export function DownloadBar(): React.JSX.Element { >