From 8ab85da67e5ce136cc6dc897c5ee0093baa38ce2 Mon Sep 17 00:00:00 2001 From: debont80 Date: Tue, 30 Jun 2026 13:29:35 -0400 Subject: [PATCH] Fix H5/H6/M21/L37-40/L47/L55/L68/L72/L76/L91/L98/L108/L165/L166 audit items H5: HistoryEntry now stores formatId+formatHasAudio; redownload passes them back to addFromUrl so the original yt-dlp format is reused, not guessed. Compound quality labels stripped to the preset prefix for old history. L72: thumbnail now passed in redownload so re-queued rows keep their art. H6: TerminalView log capped at MAX_LOG_LINES=2000 to prevent unbounded growth. M21: --audio-quality omitted for lossless audioFormats (flac/wav). L166: fmtEta hour rollover fixed in all 3 locations -- 2h00:00 not 120:00. L165: queueStats formatSpeed precision aligned with fmtBytes. L55: QueueItem suppresses sizeLabel when already in probed-format quality label. L47: probeMeta null sends empty meta event so Resolving clears via SR6. L68: notifiedBackground resets on window show for subsequent close-while-downloading. L76: dup warning falls back to URL when title is still a placeholder. L91: SettingsView onFormatSelect uses indexOf instead of unsafe tuple cast. L98: Embed chapters field gets a hint text. L108: BrowserWindow created with explicit title AeroFetch. L37: pure formatters extracted to src/main/lib/formatters.ts and unit-tested. L38: buildArgs test covers webm thumbnail suppression. L39: CROP_SQUARE_PPA test is structural not exact-string. L40: looksLikeUrl/looksLikeSingleVideo extracted to src/renderer/src/lib/urlHelpers.ts. typecheck + 242 tests + eslint + prettier green. Co-Authored-By: Claude Opus 4.8 --- CODE-AUDIT.md | 47 +++++--- src/main/buildArgs.ts | 6 +- src/main/download.ts | 63 ++--------- src/main/index.ts | 8 ++ src/main/lib/formatters.ts | 57 ++++++++++ src/renderer/src/components/DownloadBar.tsx | 8 +- .../src/components/DownloadOptionsForm.tsx | 5 +- src/renderer/src/components/HistoryView.tsx | 12 ++- src/renderer/src/components/QueueItem.tsx | 5 +- src/renderer/src/components/SettingsView.tsx | 4 +- src/renderer/src/components/TerminalView.tsx | 19 +++- src/renderer/src/lib/urlHelpers.ts | 37 +++++++ src/renderer/src/store/downloads.ts | 6 +- src/renderer/src/store/queueStats.ts | 10 +- src/renderer/src/useClipboardLink.ts | 43 +------- src/shared/ipc.ts | 8 ++ test/buildArgs.test.ts | 25 +++-- test/clipboardLink.test.ts | 3 +- test/download.test.ts | 102 ++++++++++++++++++ 19 files changed, 339 insertions(+), 129 deletions(-) create mode 100644 src/main/lib/formatters.ts create mode 100644 src/renderer/src/lib/urlHelpers.ts create mode 100644 test/download.test.ts diff --git a/CODE-AUDIT.md b/CODE-AUDIT.md index a3ee979..f8b3d62 100644 --- a/CODE-AUDIT.md +++ b/CODE-AUDIT.md @@ -20,6 +20,19 @@ L11 (Queue header counts the live queue), L50 (no "saved" for 0 cookies), L156 + reconciliation (M25 M26 L80 L81), and new unit tests (L35 isValidMediaItem, L36 compareVersions). All verified: typecheck + 234 tests + eslint + prettier green. +**Session 2026-06-30 pass 2 (quality/format/UX polish):** H5 (history re-download now stores +formatId/formatHasAudio + strips compound quality labels; thumbnail also passed — L72), H6 +(TerminalView log capped at 2000 lines), M21 (skip --audio-quality for lossless flac/wav), +L166 (fmtEta hour rollover fixed in download.ts, store/downloads.ts, queueStats.ts — "2:00:00" +not "120:00"), L165 (formatSpeed precision aligned with fmtBytes), L55 (QueueItem suppresses +sizeLabel when already in probed-format quality label), L47 (probeMeta null sends empty meta +event to clear "Resolving…"), L68 (notifiedBackground resets on window show), L76 (dup warning +falls back to URL when title is placeholder), L91 (SettingsView unsafe tuple cast fixed), L98 +(embed-chapters hint added), L108 (window title set), L37 (formatters extracted to lib/formatters.ts; +fmtBytes/fmtEta/parseProgress unit-tested including NA paths), L38 (webm thumbnail exclusion +test), L39 (CROP_SQUARE_PPA structural test), L40 (looksLikeUrl/looksLikeSingleVideo extracted +to lib/urlHelpers.ts; test imports pure module directly). All verified: typecheck + 242 tests + eslint + prettier green. + **Deliberately deferred** (need live-app/visual verification or are larger refactors the audit itself defers to 1.x): the wire-or-cut features (M5/M6/UX1), the god-file/store refactors (C1, C2, H1), the SIMP* helpers + shared-UI-token work, the CC* consolidations, @@ -183,11 +196,11 @@ token system + shared primitives (UI/SIMP — high value, larger effort) · i18n with H2's shared formatter. - [ ] **H4 — Carry raw numbers across the progress boundary.** `DownloadProgress` ships formatted `speed`/`eta` strings; `queueStats.ts` re-parses them back to numbers. -- [ ] **H5 — History re-download silently changes quality.** `HistoryView.redownload` passes the +- [x] **H5 — History re-download silently changes quality.** `HistoryView.redownload` passes the stored `quality` (for format-picker downloads this is a *label* like "720p · mp4 · 184 MB") back as `quality` with no `formatId`; `buildArgs.videoFormat()` has no matching case and falls back to `bv*+ba/b` (Best). The queued item shows "720p…" while actually fetching Best. -- [ ] **H6 — TerminalView log grows unbounded.** `setLines((ls) => [...ls, …])` with no cap; a +- [x] **H6 — TerminalView log grows unbounded.** `setLines((ls) => [...ls, …])` with no cap; a verbose run (`-F`, `--verbose`) streams thousands of lines into React state. Every other log/list in the app is capped — cap this too (and/or virtualize). - [x] **H7 — `cookies.txt` written in plaintext with no restrictive perms.** [cookies.ts](src/main/cookies.ts) @@ -269,7 +282,7 @@ token system + shared primitives (UI/SIMP — high value, larger effort) · i18n - [ ] **M20 — ProgressBar / native `