diff --git a/crates/app/src/notices.rs b/crates/app/src/notices.rs index c15198f..7a854c0 100644 --- a/crates/app/src/notices.rs +++ b/crates/app/src/notices.rs @@ -19,9 +19,9 @@ pub(crate) const NOTICES_MAX: usize = 8; pub(crate) const NOTICE_MIN_W: f32 = 180.; /// The whole of the queue's policy, where it can be read at once and tested -/// without a window: dedupe against the back, a ceiling, oldest out first. -/// [`Player::notify_user`] is the door every message comes through; this is what -/// the door does. +/// without a window: dedupe against the back, a ceiling, oldest out first -- +/// except an export's own outcome, which jumps to the front. [`Player::notify_user`] +/// is the door every message comes through; this is what the door does. pub(crate) fn push_notice(notices: &mut std::collections::VecDeque, message: SharedString) { // A repeat of what is already at the back is dropped -- holding a key that // refuses would otherwise fill the queue with one sentence, and the count on @@ -32,7 +32,22 @@ pub(crate) fn push_notice(notices: &mut std::collections::VecDeque if notices.len() >= NOTICES_MAX { notices.pop_front(); } - notices.push_back(message); + // Minutes of an export land here the moment it ends, and behind two or + // three progress lines (a proxy, a caption) queued while it ran, its own + // result would sit unseen several dismissals deep. It is the one thing a + // person started the export to read, so it goes to the front -- the + // notice showing now -- rather than the back of the line. + match is_completion(&message) { + true => notices.push_front(message), + false => notices.push_back(message), + } +} + +/// An export's own outcome: the one class of notice that outranks whatever +/// is already queued ([`push_notice`]). Named by the same prefixes +/// [`crate::player::export`] writes them with. +fn is_completion(message: &str) -> bool { + message.starts_with(EXPORT_DONE) || message.starts_with("EXPORT FAILED") } /// The tail an open/load notice grows when the file has sound the engine cannot diff --git a/crates/app/src/render.rs b/crates/app/src/render.rs index bcda1d9..541c03b 100644 --- a/crates/app/src/render.rs +++ b/crates/app/src/render.rs @@ -8,7 +8,7 @@ impl Render for Player { // A file that has just been opened sits on its first frame with the // clock stopped: opening is not playing, whichever way the file // arrived. The play binding and the transport button start it. - if let Some(session) = &mut self.session { + if let Some(session) = self.active_session_mut() { session.tick(); } self.pump(window); diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index 047fed1..b7cea15 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -153,6 +153,32 @@ fn a_second_message_queues_behind_the_first_instead_of_erasing_it() { assert_ne!(front, q.front().cloned()); } +/// An export's own outcome is what a person started it to read, so it must +/// never sit behind two progress lines queued while it ran: it jumps to the +/// front and is the one showing the moment it arrives. +#[test] +fn an_export_outcome_jumps_the_queue() { + let mut q = std::collections::VecDeque::new(); + push_notice(&mut q, "PROXY READY for a.mp4 — Proxies on cuts on it".into()); + push_notice(&mut q, "SUBTITLES b.srt — 1 track(s) in the palette".into()); + push_notice(&mut q, format!("{EXPORT_DONE}out.mp4").into()); + assert_eq!(q.len(), 3); + assert_eq!( + q.front().map(|n: &gpui::SharedString| n.as_ref()), + Some(format!("{EXPORT_DONE}out.mp4")).as_deref(), + "the export's result must be the notice showing, not third in line" + ); + + // A failed export is the same class: the outcome, whichever it was. + let mut q = std::collections::VecDeque::new(); + push_notice(&mut q, "PROXY READY for a.mp4 — Proxies on cuts on it".into()); + push_notice(&mut q, "EXPORT FAILED: disk full".into()); + assert_eq!( + q.front().map(|n: &gpui::SharedString| n.as_ref()), + Some("EXPORT FAILED: disk full") + ); +} + /// The bar colours itself off the words the message already opens with, so /// the tone cannot disagree with the sentence it labels. #[test] diff --git a/crates/app/src/tests/media.rs b/crates/app/src/tests/media.rs index 4dfeed3..8680495 100644 --- a/crates/app/src/tests/media.rs +++ b/crates/app/src/tests/media.rs @@ -1279,6 +1279,30 @@ fn a_second_session_playing_never_moves_the_first() { ); } +/// The frozen-preview regression: `render` used to call `tick` on +/// `self.session` unconditionally, so a preview session's clock -- the one +/// [`Player::pump`] actually reads while previewing -- was never advanced +/// and the picture sat on frame 0 forever. The fix routes `tick` through +/// [`Player::active_session_mut`], the same preview-first precedence +/// `pump`/`transport` already use. This proves `tick` is what a session +/// needs to keep its own clock honest, and that ticking one session leaves +/// an untouched sibling exactly where it was -- so routing it through +/// whichever session is active cannot disturb the other one. +#[test] +fn ticking_the_preview_session_never_moves_the_timeline() { + let mut timeline = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture"); + timeline.seek(0.5); + let before = timeline.now(); + + let mut preview = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture"); + preview.play(); + // Stands in for what `render` now does every frame while a preview is + // showing: only the active session -- the preview -- gets ticked. + preview.tick(); + + assert_eq!(timeline.now(), before, "ticking the preview moved the timeline's clock"); +} + /// [`bgra_to_rgba`] and [`save_screenshot`]'s own PNG write, round-tripped: a /// synthetic 2x2 frame -- one pixel per corner, alpha and channel order all /// distinct -- decodes back to the same pixels a viewer would see, in RGBA.