Skip to main content

max / audiofiles

Draw the sweep into the pane, not a window over an empty one `ImportMode::Cleaning` is a full-screen mode and the shipped `draw_cleanup_progress` took the pane over, but the import flip left `draw_sweep` on the window helper it had while it sat beside that screen. So the flipped app drew the sweep floating over nothing. It compiled because `egui::Ui` derefs to `Context`, so `draw_sweep(ui, state)` silently passed `ui.ctx()` where a `&mut Ui` was meant. Worth knowing: that deref will hide the same mistake anywhere a host function takes a context and its caller has a ui. Found by writing the fidelity test the sweep did not have, which is the last served screen that was missing one.
Co-Authored-By
Claude Opus 5 (1M context) <noreply@anthropic.com>
Author: Max Johnson <me@maxj.phd> · 2026-08-22 23:34 UTC
Signed with PGP, not checked
Commit: c55ce942b005f309b2c01c29f3519421e95ee4e5
Parent: a2ad3f8
2 files changed, +30 insertions, -17 deletions
@@ -391,12 +391,16 @@
391 391 apply(ui.ctx(), state, None, intents.into_inner());
392 392 }
393 393
394 - /// Draw the described sweep, and act on whatever was pressed.
394 + /// Draw the blob sweep, and act on whatever was pressed.
395 395 ///
396 - /// Its own window rather than a stage of the import flow's, because it is not
397 - /// one: see `importing`'s header. Refreshed unconditionally for the plainest of
398 - /// the reasons -- a worker is removing rows and the count moves on its own.
399 - pub fn draw_sweep(ctx: &egui::Context, state: &mut BrowserState) {
396 + /// Its own address rather than a stage of the import flow, because it is not
397 + /// one: see `importing`'s header. Into the app's own pane all the same, because
398 + /// `ImportMode::Cleaning` is a full-screen mode like every other stage and the
399 + /// shipped `draw_cleanup_progress` took the pane over.
400 + ///
401 + /// Refreshed unconditionally for the plainest of the reasons: a worker is
402 + /// removing rows and the count moves on its own.
403 + pub fn draw_sweep(ui: &mut egui::Ui, state: &mut BrowserState) {
400 404 let intents = RefCell::new(Vec::new());
401 405 let mut runtime = state.described.sweep.take();
402 406 let host = Host {
@@ -405,19 +409,9 @@
405 409 themes: themes(),
406 410 intents: &intents,
407 411 };
408 - let closed = window(
409 - ctx,
410 - "Cleaning up (described)",
411 - &mut runtime,
412 - &host,
413 - "/cleanup",
414 - true,
415 - );
412 + inline(ui, &mut runtime, &host, "/cleanup", true);
416 413 state.described.sweep = runtime;
417 - apply(ctx, state, None, intents.into_inner());
418 - if closed {
419 - state.described.sweep = None;
420 - }
414 + apply(ui.ctx(), state, None, intents.into_inner());
421 415 }
422 416
423 417 /// Draw the loose-files warning, and act on whatever was pressed.
@@ -1197,3 +1197,22 @@
1197 1197 println!(" {stage}: ok");
1198 1198 }
1199 1199 }
1200 +
1201 + #[test]
1202 + fn the_sweep_serves_what_it_describes() {
1203 + let (mut state, _dir) = fixture();
1204 + state.import_wf.import_mode = crate::state::ImportMode::Cleaning {
1205 + completed: 3,
1206 + total: 9,
1207 + current_name: "kick.wav".to_owned(),
1208 + };
1209 +
1210 + let described = described(&super::panel::described_screen(&state, "/cleanup"));
1211 + let drawn = shipped(|ui| {
1212 + super::panel::draw_sweep(ui, &mut state);
1213 + });
1214 +
1215 + described.addresses_resolve();
1216 + // Into the pane, like every other full-screen mode, so no frame to discount.
1217 + Parity::strict().assert(&described, &drawn);
1218 + }