diff --git a/README.md b/README.md
index bea78e6..db95db3 100644
--- a/README.md
+++ b/README.md
@@ -4,12 +4,7 @@
Platter
- Your iPod Classic, without iTunes.
-
-
- Browse, edit and grow the music library on a click-wheel iPod —
- imports, conversion, cover art and listening stats, all in one place.
-
+ iPod without iTunes — a native macOS app that manages your library.
@@ -29,87 +24,59 @@
·
Build from source
·
- Safety
- ·
Requirements
-
+
+
+
-> [!NOTE]
-> Platter drives a real iPod Classic through **libgpod** — the same open-source
-> engine gtkpod used — wrapped in a native macOS app. Plug the iPod in, and its
-> library is yours to manage. No iTunes, no Music.app, no cloud.
+
## Features
-### Library
+### Your music, the way you left it
-- **Browse** the iPod grouped by artist, album or genre, with cover art and
- per-album track counts. The list is virtualized — a library of tens of
- thousands of tracks scrolls without breaking a sweat
-- **Search** as you type across title, artist, album and genre
-- **Edit** one track in the inspector, or select thousands (⌘-click,
- shift-click, per-artist and per-album select-all) and stamp artist, album,
- composer or genre across all of them in one apply
-- **Cover art**: set or replace covers for any selection; albums missing art
- are counted right on their headers
-- **Capacity gauge** shows what's free before and after every import
+- Plug the iPod in and everything on it shows up — grouped by artist, album or
+ genre, cover art and all
+- Search as you type
+- Scrolls smoothly whether you have 80 tracks or 80,000
+- See how much space is free before and after you add anything
-### Importing
+### Fix the messy tags
-- **Drag and drop** files or folders anywhere on the window
-- **From Drive** scans a whole mounted disk and tells you exactly how many
- tracks an import would bring in before anything is copied
-- MP3 and M4A/AAC import directly; **FLAC, WAV, AIFF, APE, WavPack, DSD and
- `.cue` album images are converted to Apple Lossless** automatically, tags
- and art included
-- Long imports post a system notification when they finish while you're in
- another app
+- Click a track and edit it, or select a whole album — or a whole artist — and
+ fix the artist, album, composer or genre for all of them at once
+- Add or replace cover art for anything you've selected
+- Albums missing artwork are counted right on their header, so you can see what
+ still needs a cover
-### Convert
+### Add music
-- A standalone converter to iPod-ready formats — to the device or to a folder,
- with per-file size estimates, a live log, and formats probed from the
- bundled ffmpeg so nothing is offered that can't be produced
+- Drag files or folders anywhere onto the window
+- Or point Platter at an external drive and it'll tell you how much it would
+ add before it copies a thing
+- MP3 and AAC go straight on. FLAC, WAV, AIFF, APE, WavPack, DSD and `.cue`
+ albums are converted for you, tags and artwork included
+- Big imports notify you when they're done, so you can go do something else
-### Stats
+### Convert on its own
-- Lifetime plays, listening time, library coverage and top albums, read from
- the iPod's own play counts
-- An **activity heatmap** of your listening, and a **share card** rendered to
- the clipboard as an image
+- A converter you can use by itself — put the result on the iPod or in a
+ folder, see the size before you commit, watch it work
-### Devices
+### See what you actually listened to
-- Model detection from the iPod's own SysInfo — a Classic shows up as a
- Classic, with the right glyph and generation
-- Devices Platter positively can't manage (iPhone/iPod Touch, 3rd/4th-gen
- Shuffle) are shown and labeled rather than hidden
-- Eject from the toolbar; the last-connected iPod reconnects at launch
+- Lifetime plays, hours listened and top albums, taken from the iPod's own
+ counts
+- A heatmap of your listening year, and a share card you can copy as an image
-### Settings
+### Make it yours
-- Light, dark, or follow-the-system theme
-- Alternate Dock icons
+- Light, dark or match the system
+- Pick a different Dock icon
- ⌘1 / ⌘2 / ⌘3 switch tabs, ⌘, opens Settings
-## Safety
-
-An iPod's database has no undo, so Platter is conservative by design:
-
-- **Paired backups.** The iTunesDB and the device's Play Counts file are
- backed up together — at connect and again before writes. They are only
- coherent as a pair, and Platter never copies one without the other
-- **Play counts survive.** Fresh plays recorded by the device are merged, then
- written back — nothing your iPod counted is lost
-- **Edits coalesce** into a single database write after a short idle window,
- cutting flash wear; quitting waits for the write to finish
-- **Failures are loud.** A background save that fails raises a persistent
- alert, not a log line. Crash and error logs land in
- `~/Library/Logs/com.kolebaev.platter/platter.log` — attach that file to bug
- reports
-
## Installation
[**Download the latest DMG**](https://github.com/kolebayev/platter/releases/latest/download/Platter_macOS_arm64.dmg)
@@ -121,14 +88,21 @@ same recipe, downloadable with a GitHub account. Or
[build from source](#build-from-source).
1. Open the `.dmg` and drag Platter to Applications
-2. Open Platter and connect your iPod
-3. Click **Open Privacy Settings** when prompted and enable Platter under
- **Privacy & Security → Files & Folders → Removable Volumes**, then relaunch
-> [!TIP]
-> Builds are ad-hoc signed (no Developer ID), so macOS reports them as
-> "damaged". Clear the quarantine flag once:
-> `xattr -dr com.apple.quarantine /Applications/Platter.app`
+2. Run this once in Terminal:
+
+ ```sh
+ xattr -dr com.apple.quarantine /Applications/Platter.app
+ ```
+
+ Builds are ad-hoc signed rather than notarized, so without this macOS
+ refuses to open the app — "Apple could not verify Platter is free of
+ malware". The command clears the download flag; you only need it once.
+
+3. Open Platter and connect your iPod
+
+4. Click **Open Privacy Settings** when prompted and enable Platter under
+ **Privacy & Security → Files & Folders → Removable Volumes**, then relaunch
## Build from source
@@ -213,10 +187,8 @@ bitrates, `--covers` replaces art in place).
## Requirements
- macOS 14 or later, Apple Silicon (no Intel build)
-- A click-wheel iPod in disk mode — Classic 6th/7th generation is the primary
- target; models with an iTunesDB that libgpod recognizes also work
-- Not supported: iPhone / iPod Touch (SQLite library) and 3rd/4th-generation
- Shuffle (a different iTunesSD layout)
+- An iPod Classic in disk mode
+- Not supported: iPhone / iPod Touch and 3rd/4th-generation Shuffle
## Privacy
diff --git a/assets/screenshot.png b/assets/screenshot.png
new file mode 100644
index 0000000..ab8d26a
Binary files /dev/null and b/assets/screenshot.png differ
diff --git a/tauri-src/src/commands.rs b/tauri-src/src/commands.rs
index 4cea14c..e83f2e2 100644
--- a/tauri-src/src/commands.rs
+++ b/tauri-src/src/commands.rs
@@ -1260,6 +1260,15 @@ struct JobEvents {
done: AtomicUsize,
/// Display name of the most recently started file.
current: std::sync::Mutex,
+ /// What each finished file turned out to be, by batch index. Arrives just
+ /// before the outcome it belongs to and is consumed by the line written
+ /// there, so the map holds at most one entry per running worker.
+ stats: std::sync::Mutex>,
+ /// Name and start instant of every file still converting, by batch index.
+ /// The log line for a finished track is written where the outcome is known
+ /// (`item_done`), which is handed an index and nothing else — the name and
+ /// the clock have to be carried over from `started`.
+ in_flight: std::sync::Mutex>,
pending: std::sync::Mutex>,
pending_items: std::sync::Mutex>,
last_flush: std::sync::Mutex,
@@ -1277,6 +1286,8 @@ impl JobEvents {
seq: AtomicUsize::new(0),
done: AtomicUsize::new(0),
current: std::sync::Mutex::new(String::new()),
+ in_flight: std::sync::Mutex::new(std::collections::HashMap::new()),
+ stats: std::sync::Mutex::new(std::collections::HashMap::new()),
pending: std::sync::Mutex::new(Vec::new()),
pending_items: std::sync::Mutex::new(Vec::new()),
last_flush: std::sync::Mutex::new(std::time::Instant::now()),
@@ -1375,7 +1386,15 @@ impl JobEvents {
impl convert::ConvertObserver for JobEvents {
fn started(&self, index: usize, name: &str) {
*self.current.lock().unwrap_or_else(|e| e.into_inner()) = name.to_string();
+ self.in_flight
+ .lock()
+ .unwrap_or_else(|e| e.into_inner())
+ .insert(index, (name.to_string(), std::time::Instant::now()));
self.push_status(index, "converting", None);
+ // One line per track, not one per run: a job that converted everything
+ // used to leave a log holding a header, a footer and whatever ffmpeg
+ // happened to complain about, with no record of the tracks themselves.
+ self.push_line("cmd", Some(name), "converting…");
self.emit_progress("converting", Some(0.0));
}
@@ -1383,17 +1402,67 @@ impl convert::ConvertObserver for JobEvents {
self.emit_progress("converting", Some(fraction));
}
+ fn wants_stats(&self) -> bool {
+ true
+ }
+
+ fn item_stats(&self, index: usize, stats: &convert::OutputStats) {
+ self.stats
+ .lock()
+ .unwrap_or_else(|e| e.into_inner())
+ .insert(index, stats.clone());
+ }
+
fn log(&self, level: &'static str, file: Option<&str>, line: &str) {
self.push_line(level, file, line);
}
fn item_done(&self, index: usize, outcome: &convert::Prepared) {
+ let started = self
+ .in_flight
+ .lock()
+ .unwrap_or_else(|e| e.into_inner())
+ .remove(&index);
+ // Cancelled items can reach this without a `started` — the worker loop
+ // checks the flag before it claims an index.
+ let (name, took) = match started {
+ Some((name, at)) => (Some(name), Some(at.elapsed())),
+ None => (None, None),
+ };
+ let took = took.map(|d| format!(" in {:.1}s", d.as_secs_f64()));
+ let took = took.as_deref().unwrap_or("");
+ let stats = self
+ .stats
+ .lock()
+ .unwrap_or_else(|e| e.into_inner())
+ .remove(&index);
match outcome {
- convert::Prepared::Ready(_) => self.push_status(index, "converted", None),
+ convert::Prepared::Ready(_) => {
+ self.push_status(index, "converted", None);
+ let what = stats.map(|s| format!(" · {}", s.summary()));
+ self.push_line(
+ "ok",
+ name.as_deref(),
+ &format!("converted{took}{}", what.as_deref().unwrap_or("")),
+ );
+ }
convert::Prepared::Rejected(reason) => {
- self.push_status(index, "failed", Some(reason.as_str()))
+ self.push_status(index, "failed", Some(reason.as_str()));
+ // A conversion failure carries ffmpeg's whole stderr tail, and
+ // every line of it already reached the log under this same
+ // name — printing the joined copy too says it all twice. The
+ // rejections that never spawned ffmpeg (unreadable source, bad
+ // cue) are the ones whose text nothing else logged.
+ let line = match reason.starts_with("conversion failed:") {
+ true => format!("failed{took}"),
+ false => format!("failed{took}: {reason}"),
+ };
+ self.push_line("error", name.as_deref(), &line);
+ }
+ convert::Prepared::Cancelled => {
+ self.push_status(index, "cancelled", None);
+ self.push_line("cmd", name.as_deref(), "cancelled");
}
- convert::Prepared::Cancelled => self.push_status(index, "cancelled", None),
}
}
diff --git a/tauri-src/src/convert.rs b/tauri-src/src/convert.rs
index 8928991..99ebbd5 100644
--- a/tauri-src/src/convert.rs
+++ b/tauri-src/src/convert.rs
@@ -1150,6 +1150,10 @@ fn muxer_args(format: TargetFormat) -> Vec {
/// also silence the warnings that do mean something.
fn is_self_inflicted_noise(line: &str) -> bool {
line.contains("extension is not .m4a nor .m4v")
+ // swscale says this about the cover art whenever we normalize one —
+ // it is a remark about the JPEG we chose to re-encode, fires on every
+ // track of an album with art, and names nothing the user can act on.
+ || line.contains("deprecated pixel format used")
}
fn run_ffmpeg(
@@ -1323,10 +1327,17 @@ fn convert_one(
};
let tmp = dst.with_extension(format!("{}.part", target.format.ext()));
- let display = dst
- .file_name()
- .map(|n| n.to_string_lossy().into_owned())
- .unwrap_or_default();
+ // The name the rest of the log already uses for this track — `WorkItem::
+ // display`: the source file, except for a cue slice, which has no file of
+ // its own and is known by what it is being written as. ffmpeg's lines used
+ // to carry the destination instead, so one track appeared in the log under
+ // two names, once as .flac and once as .m4a.
+ let display = match cue {
+ Some(_) => dst.file_stem(),
+ None => src.file_name(),
+ }
+ .map(|n| n.to_string_lossy().into_owned())
+ .unwrap_or_default();
// A cue slice's span, not the whole album image — otherwise the per-file
// bar for track 1 of 12 would creep to 8% and stop.
let effective_duration = match cue {
@@ -1494,6 +1505,33 @@ fn prepare_one(
control: &ConvertControl,
obs: &dyn ConvertObserver,
index: usize,
+) -> Prepared {
+ let outcome = prepare_one_uncounted(
+ item, out_dir, layout, names, art_cache, target, control, obs, index,
+ );
+ // Reading the result back covers the passthrough branches too, which
+ // produce a "converted" file nothing in this function ever encoded.
+ if let (Prepared::Ready(path), true) = (&outcome, obs.wants_stats()) {
+ if let Some(tools) = tools() {
+ if let Some(probe) = probe_media(&tools.ffprobe, path) {
+ obs.item_stats(index, &OutputStats::from_probe(&probe, path));
+ }
+ }
+ }
+ outcome
+}
+
+#[allow(clippy::too_many_arguments)]
+fn prepare_one_uncounted(
+ item: &WorkItem,
+ out_dir: &Path,
+ layout: OutLayout,
+ names: &NameReserver,
+ art_cache: &ArtCache,
+ target: &TargetSpec,
+ control: &ConvertControl,
+ obs: &dyn ConvertObserver,
+ index: usize,
) -> Prepared {
let to_alac = target.format == TargetFormat::Alac;
@@ -1603,8 +1641,114 @@ pub fn reject_pairing(probe: &MediaProbe, target: &TargetSpec) -> Option
/// Everything a caller can learn while a batch runs. The old callback fired
/// only when an item finished, which left the bar frozen for the length of one
/// ten-minute DSD file.
+/// Decimal units, matching `formatBytes` in the UI — a log line reading 27.3 MB
+/// beside a footer reading 28.6 MB for the same bytes is its own bug report.
+fn format_bytes(bytes: u64) -> String {
+ if bytes < 1000 {
+ return format!("{bytes} B");
+ }
+ let mut value = bytes as f64;
+ let mut unit = "B";
+ for u in ["KB", "MB", "GB", "TB"] {
+ value /= 1000.0;
+ unit = u;
+ if value < 1000.0 {
+ break;
+ }
+ }
+ let digits = if value < 10.0 {
+ 2
+ } else if value < 100.0 {
+ 1
+ } else {
+ 0
+ };
+ format!("{value:.digits$} {unit}")
+}
+
+/// What one finished file actually turned out to be, read back from the output
+/// instead of derived from the request. A passthrough that skipped the encode,
+/// an encoder that clamped a rate, or a VBR pass that landed nowhere near its
+/// nominal bitrate would all be reported as whatever was asked for otherwise.
+#[derive(Clone, Debug)]
+pub struct OutputStats {
+ /// Upper-cased for display: ALAC, MP3, AAC, FLAC, PCM.
+ pub codec: String,
+ pub sample_rate: u32,
+ pub channels: u32,
+ /// None for lossy output, where bit depth belongs to the decoder rather
+ /// than to the file.
+ pub bits: Option,
+ pub bytes: u64,
+ /// Averaged over the whole file. Exact, unlike a nominal encoder setting.
+ pub kbps: u32,
+}
+
+impl OutputStats {
+ /// "ALAC 16-bit 44.1 kHz stereo · 27.3 MB · 916 kbps" — what the file is,
+ /// then how big it came out, which is the order someone reads it in.
+ pub fn summary(&self) -> String {
+ let mut out = self.codec.clone();
+ if let Some(bits) = self.bits {
+ out.push_str(&format!(" {bits}-bit"));
+ }
+ if self.sample_rate > 0 {
+ let khz = self.sample_rate as f64 / 1000.0;
+ // 44.1 and 88.2 need the decimal; on 48 and 96 it is noise.
+ if (khz - khz.round()).abs() < 0.05 {
+ out.push_str(&format!(" {khz:.0} kHz"));
+ } else {
+ out.push_str(&format!(" {khz:.1} kHz"));
+ }
+ }
+ match self.channels {
+ 0 => {}
+ 1 => out.push_str(" mono"),
+ 2 => out.push_str(" stereo"),
+ n => out.push_str(&format!(" {n} ch")),
+ }
+ out.push_str(&format!(" · {}", format_bytes(self.bytes)));
+ if self.kbps > 0 {
+ out.push_str(&format!(" · {} kbps", self.kbps));
+ }
+ out
+ }
+
+ fn from_probe(probe: &MediaProbe, path: &Path) -> OutputStats {
+ let bytes = match probe.file_bytes {
+ 0 => std::fs::metadata(path).map(|m| m.len()).unwrap_or(0),
+ n => n,
+ };
+ let bps = match probe.bit_rate {
+ 0 if probe.duration_s > 0.0 => (bytes as f64 * 8.0 / probe.duration_s) as u64,
+ n => n,
+ };
+ let codec = match probe.codec.strip_prefix("pcm_") {
+ Some(_) => "PCM".to_string(),
+ None => probe.codec.to_uppercase(),
+ };
+ OutputStats {
+ codec,
+ sample_rate: probe.sample_rate,
+ channels: probe.channels,
+ bits: probe.is_lossless().then_some(probe.bits),
+ bytes,
+ kbps: (bps / 1000) as u32,
+ }
+ }
+}
+
pub trait ConvertObserver: Sync {
fn started(&self, _index: usize, _name: &str) {}
+ /// Whether to read each finished file back. The probe costs one ffprobe
+ /// spawn per item, which is worth it for the Convert tab's log and pure
+ /// waste for the drag-and-drop import, whose observer only counts files.
+ fn wants_stats(&self) -> bool {
+ false
+ }
+ /// What the finished file turned out to be. Emitted before `item_done`,
+ /// and only for items that produced one.
+ fn item_stats(&self, _index: usize, _stats: &OutputStats) {}
/// 0..1 within the current file. Never called for stream-copy items or
/// sources whose duration is unknown — there is no denominator.
fn file_progress(&self, _index: usize, _fraction: f64) {}
@@ -1750,13 +1894,11 @@ pub fn prepare_batch_into(
let art_cache = ArtCache::new(&art_dir);
let names = NameReserver::new(out_dir);
- // Half the cores: ffmpeg's ALAC path is single-threaded but the decode +
- // resample chain still saturates a core; leave headroom for the UI.
- let workers = std::thread::available_parallelism()
- .map(|n| n.get() / 2)
- .unwrap_or(4)
- .clamp(2, 8)
- .min(items.len());
+ // Two, whatever the machine has. Half the cores left the UI responsive but
+ // not the audio: eight decode+resample chains starve CoreAudio's render
+ // thread, and music playing while a batch runs stutters. Two still halves
+ // the wall clock against a plain queue, which is where most of the win was.
+ let workers = 2.min(items.len());
let next = AtomicUsize::new(0);
let done = AtomicUsize::new(0);
@@ -2020,6 +2162,57 @@ mod tests {
));
}
+ fn stats(codec: &str, rate: u32, ch: u32, bits: Option, bytes: u64, kbps: u32) -> OutputStats {
+ OutputStats {
+ codec: codec.into(),
+ sample_rate: rate,
+ channels: ch,
+ bits,
+ bytes,
+ kbps,
+ }
+ }
+
+ #[test]
+ fn a_lossless_output_is_described_with_its_depth_and_rate() {
+ assert_eq!(
+ stats("ALAC", 44100, 2, Some(16), 27_300_000, 916).summary(),
+ "ALAC 16-bit 44.1 kHz stereo · 27.3 MB · 916 kbps"
+ );
+ // 48 and 96 kHz read as noise with a trailing .0.
+ assert_eq!(
+ stats("FLAC", 48000, 1, Some(24), 9_540_000, 1411).summary(),
+ "FLAC 24-bit 48 kHz mono · 9.54 MB · 1411 kbps"
+ );
+ }
+
+ #[test]
+ fn a_lossy_output_claims_no_bit_depth() {
+ // Bit depth for MP3/AAC is a property of whatever decodes it, so the
+ // probe's inferred value must not be presented as a fact about the file.
+ assert_eq!(
+ stats("MP3", 44100, 2, None, 9_500_000, 192).summary(),
+ "MP3 44.1 kHz stereo · 9.50 MB · 192 kbps"
+ );
+ }
+
+ #[test]
+ fn an_unknown_bitrate_is_left_out_rather_than_printed_as_zero() {
+ assert_eq!(
+ stats("PCM", 44100, 2, Some(16), 1000, 0).summary(),
+ "PCM 16-bit 44.1 kHz stereo · 1.00 KB"
+ );
+ }
+
+ #[test]
+ fn the_cover_art_scalers_pixel_format_warning_is_dropped() {
+ // The literal swscale emits while normalizing a cover, once per track
+ // of an album that has one.
+ assert!(is_self_inflicted_noise(
+ "[swscaler @ 0x7e2bf0000] deprecated pixel format used, make sure you did set range correctly"
+ ));
+ }
+
#[test]
fn real_warnings_survive_the_filter() {
// Nothing here is caused by the .part name, so all of it has to reach
diff --git a/ui/components/ArtworkThumb.tsx b/ui/components/ArtworkThumb.tsx
index cc65aaf..651258d 100644
--- a/ui/components/ArtworkThumb.tsx
+++ b/ui/components/ArtworkThumb.tsx
@@ -4,6 +4,7 @@ import {
artworkFetchSize,
cachedArtwork,
getArtVersion,
+ markArtworkUndecodable,
releaseArtwork,
resolvedArtwork,
retainArtwork,
@@ -77,6 +78,15 @@ export function ArtworkThumb({
className,
)}
alt=""
+ // A cover the webview cannot decode would otherwise paint WebKit's
+ // broken-image icon — the macOS system question mark, which looks
+ // like a foreign asset dropped into the UI. Fall back to our own
+ // placeholder and tell the cache, so the other thumbs on this key
+ // never paint it either.
+ onError={() => {
+ if (trackId) markArtworkUndecodable(trackId, fetchSize);
+ setSrc(null);
+ }}
/>
);
}
diff --git a/ui/components/ConvertView.tsx b/ui/components/ConvertView.tsx
index def8b0b..454a09a 100644
--- a/ui/components/ConvertView.tsx
+++ b/ui/components/ConvertView.tsx
@@ -888,6 +888,25 @@ function EstimatePanel({
);
}
+/** The log pane's palette, keyed by who is speaking.
+ *
+ * The colours are the queue's, not a second scheme invented for this pane:
+ * `ok` is the same emerald a finished row uses and `error` the same
+ * destructive red, so a track that went green in the list is green here too.
+ *
+ * The rest is a deliberate hierarchy rather than one colour per level. The
+ * lines this app writes about its own progress (`cmd`) sit muted, because a
+ * successful album is mostly those and they are context, not news. ffmpeg's
+ * warnings keep amber. What a reader actually scans for — landed, failed —
+ * takes the only two saturated colours in the pane. */
+const LOG_LEVELS: Record = {
+ cmd: { glyph: "·", color: "text-muted-foreground" },
+ info: { glyph: "·", color: "text-foreground" },
+ ok: { glyph: "✓", color: DONE_TONE },
+ warn: { glyph: "!", color: "text-amber-600 dark:text-amber-500" },
+ error: { glyph: "✕", color: "text-destructive" },
+};
+
function ConvertFooter({
running,
progress,
@@ -939,19 +958,19 @@ function ConvertFooter({
{log.length === 0 ? (
No output yet.
) : (
- log.map((line) => (
-
- {line.file ? `${line.file}: ${line.line}` : line.line}
-
- ))
+ log.map((line) => {
+ const style = LOG_LEVELS[line.level] ?? LOG_LEVELS.info;
+ return (
+
+ {/* The glyph column is what makes a run scannable: an album
+ is a wall of identical-looking lines, and the eye finds
+ ✓/✕ far faster than it reads. */}
+ {style.glyph}
+ {line.file && {line.file}: }
+ {line.line}
+
+ );
+ })
)}
)}
diff --git a/ui/components/ImportDialog.tsx b/ui/components/ImportDialog.tsx
index 8669765..5cbe953 100644
--- a/ui/components/ImportDialog.tsx
+++ b/ui/components/ImportDialog.tsx
@@ -30,6 +30,12 @@ export function ImportDialog({
onImport: (items: PendingImport[]) => Promise;
}) {
const [pending, setPending] = useState([]);
+ // File paths whose embedded cover the webview could not decode. Purely a
+ // display concern — the bytes still go to the backend on import, which
+ // decodes them with gdk-pixbuf, not WebKit — but without this an
+ // undecodable cover paints WebKit's broken-image icon, the macOS system
+ // question mark, instead of the placeholder beside every other row.
+ const [undecodableArt, setUndecodableArt] = useState>(new Set());
const [loading, setLoading] = useState(false);
const [importing, setImporting] = useState(false);
// Bumped on close: a tag read still in flight when the user cancels must
@@ -40,6 +46,7 @@ export function ImportDialog({
if (!next) {
generationRef.current++;
setPending([]);
+ setUndecodableArt(new Set());
}
onOpenChange(next);
}
@@ -136,11 +143,14 @@ export function ImportDialog({
{pending.map((item, i) => (
- {item.artworkDataUrl ? (
+ {item.artworkDataUrl && !undecodableArt.has(item.filePath) ? (

+ setUndecodableArt((s) => new Set(s).add(item.filePath))
+ }
/>
) : (
diff --git a/ui/lib/api.test.ts b/ui/lib/api.test.ts
new file mode 100644
index 0000000..8184d0e
--- /dev/null
+++ b/ui/lib/api.test.ts
@@ -0,0 +1,69 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+const invoke = vi.fn<(cmd: string, args?: unknown) => Promise
>();
+vi.mock("@tauri-apps/api/core", () => ({
+ invoke: (cmd: string, args?: unknown) => invoke(cmd, args),
+}));
+
+const {
+ cachedArtwork,
+ invalidateArtwork,
+ markArtworkUndecodable,
+ resolvedArtwork,
+ retainArtwork,
+} = await import("./api");
+
+const URL_A = "data:image/jpeg;base64,AAAA";
+const fetches = () => invoke.mock.calls.filter(([cmd]) => cmd === "get_artwork").length;
+
+/** Loads one cover through the scheduler the way a mounted thumb does. */
+async function load(id: string, size: number) {
+ retainArtwork(id, size);
+ return cachedArtwork(id, size);
+}
+
+describe("artwork cache", () => {
+ beforeEach(() => {
+ invalidateArtwork();
+ invoke.mockReset();
+ invoke.mockResolvedValue(URL_A);
+ });
+
+ it("marks a cover the webview could not decode as no art", async () => {
+ expect(await load("7", 80)).toBe(URL_A);
+ expect(resolvedArtwork("7", 80)).toBe(URL_A);
+
+ markArtworkUndecodable("7", 80);
+
+ // Every later mount of this key paints the placeholder instead of
+ // WebKit's broken-image icon...
+ expect(resolvedArtwork("7", 80)).toBeNull();
+ // ...without asking the backend for the same undecodable bytes again.
+ const before = fetches();
+ expect(await cachedArtwork("7", 80)).toBeNull();
+ expect(fetches()).toBe(before);
+ });
+
+ it("keeps the mark to that track and size", async () => {
+ await load("7", 80);
+ await load("7", 320);
+ await load("9", 80);
+
+ markArtworkUndecodable("7", 80);
+
+ expect(resolvedArtwork("7", 320)).toBe(URL_A);
+ expect(resolvedArtwork("9", 80)).toBe(URL_A);
+ });
+
+ it("drops the mark when the cover is replaced", async () => {
+ await load("7", 80);
+ markArtworkUndecodable("7", 80);
+
+ invalidateArtwork(["7"]);
+
+ expect(resolvedArtwork("7", 80)).toBeUndefined();
+ const before = fetches();
+ expect(await load("7", 80)).toBe(URL_A);
+ expect(fetches()).toBe(before + 1);
+ });
+});
diff --git a/ui/lib/api.ts b/ui/lib/api.ts
index fd15821..48b6e55 100644
--- a/ui/lib/api.ts
+++ b/ui/lib/api.ts
@@ -261,6 +261,31 @@ export function resolvedArtwork(id: string, size: number): string | null | undef
return artworkResolved.get(`${id}@${size}`);
}
+/** Republishes a cover the webview refused to decode as "no art".
+ *
+ * A data URL that fails to paint is not a missing cover as far as the
+ * is concerned — WebKit swaps in its own broken-image icon, which on macOS is
+ * the system question-mark tile: foreign to this UI and unreadable as either
+ * "no cover" or "bug". The thumb reports the failure here instead, so this
+ * key falls back to the music-note placeholder for every mount, not just the
+ * one that happened to paint it. The mark is an ordinary cache entry, so
+ * invalidateArtwork drops it and a replaced cover is fetched again. */
+export function markArtworkUndecodable(id: string, size: number) {
+ const key = `${id}@${size}`;
+ const url = artworkResolved.get(key);
+ log.warn("artwork undecodable", {
+ id,
+ size,
+ // The whole data URL is megabytes of base64; its head is the part that
+ // says which encoder produced it, which is what a mime/bytes mismatch
+ // shows up in.
+ head: typeof url === "string" ? url.slice(0, 32) : String(url),
+ });
+ artworkResolved.set(key, null);
+ artworkPromises.set(key, Promise.resolve(null));
+ trimArtworkCaches();
+}
+
/** Bumped on every invalidation; ArtworkThumb subscribes so already-mounted
* thumbs refetch when their track's cover was replaced (their trackId prop
* doesn't change in that case, so nothing else would re-run the effect). */
diff --git a/ui/lib/types.ts b/ui/lib/types.ts
index 22c1147..3a815fa 100644
--- a/ui/lib/types.ts
+++ b/ui/lib/types.ts
@@ -253,7 +253,10 @@ export interface ConvertProgress {
export interface ConvertLogLine {
seq: number;
- level: "info" | "warn" | "error" | "cmd";
+ /** Who is speaking, not how loud. `cmd` is this app narrating what it is
+ * about to do, `ok` is a track that landed, `info` is the job talking about
+ * itself, and `warn`/`error` are ffmpeg's own words. */
+ level: "info" | "ok" | "warn" | "error" | "cmd";
file: string | null;
line: string;
}