From 601dec3f34ef478fdd9083c089b8b571b5e03d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 19 Aug 2026 21:16:52 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(app):=20an=20export's=20own?= =?UTF-8?q?=20result=20cannot=20get=20buried=20in=20the=20queue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit push_notice queued strictly oldest-first, so an EXPORT DONE landing behind a PROXY READY and a caption notice sat three dismissals deep -- the one line a person started the export to read was the one they never saw. Export outcomes (done or failed) now jump to the front of the queue instead of the back. --- crates/app/src/notices.rs | 23 +++++++++++++++++++---- crates/app/src/tests/layout.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 4 deletions(-) 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/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]