forge
Explore
Log in

Don't you dare go Hollow

Two failures in a row are two messages, in order

Browse files at this commit

fc6f9b0d9bdf209c4ff15da41a2b2cc7f59ec9abAhmet Kaan GümüşParent: 2c8e3aa
  • feat
    • two failures in a row are two messages, in order
Show full message
✨ feat(ui): two failures in a row are two messages, in order

The notice was a slot, so the second import to fail in the same frame was
the first one's grave: `self.notice = Some(..)` at seventy call sites, each
of them overwriting whatever had not been drawn yet. The user's own case --
two files on argv, both refused for different reasons -- showed exactly one
of them.

It is a queue now. `Player::notify_user` is the one door every message comes
through, so "queued rather than overwritten" is a property of the field
instead of seventy call sites remembering to be polite, and the policy it
enforces lives in `push_notice` where it can be read at once and tested
without a window: a repeat of what is already at the back is dropped (a held
key that refuses would otherwise fill the queue with one sentence), eight is
the ceiling, and the oldest goes first.

The bar says how many are behind it -- a queue nobody is told about is a
queue whose second message reads as the first one failing to go away -- and
any key or a click answers the front one and brings the next up. The tone is
read off the words the message already opens with and drawn as a stripe down
the leading edge: a full red bar at every refusal is an alarm, and most of
these are answers.

Escape is untouched: cancelling an export is hidden while nothing is
exporting, so answering a notice with escape cannot arm a refusal behind it.
crates/app/src/main.rsmodified+168 -80
@@ -1468,10 +1468,14 @@ struct Player {
1468 /// The action whose row is waiting for a stroke. The next key that is1468 /// The action whose row is waiting for a stroke. The next key that is
1469 /// neither escape nor a lone modifier becomes the whole of what reaches it.1469 /// neither escape nor a lone modifier becomes the whole of what reaches it.
1470 rebinding: Option<ActionId>,1470 rebinding: Option<ActionId>,
1471- /// What the last file action had to say. Holds its own bar above the panel1471+ /// What the file actions have had to say, oldest first. A *queue* and not a
1472- /// until it is answered -- any key retires it, so does a click on it -- so a1472+ /// slot: two imports that fail back to back used to be one message, because
1473- /// failure is read in full instead of blinking past.1473+ /// the second overwrote the first before a frame had drawn it -- the failure
1474- notice: Option<SharedString>,1474+ /// a user never learns about is the one that was answered by another
1475+ /// failure. The front holds its own bar above the panel until it is answered
1476+ /// -- any key retires it, so does a click on it -- the bar says how many are
1477+ /// behind it, and answering it brings the next one up.
1478+ notices: std::collections::VecDeque<SharedString>,
1475 /// What the last finished export wrote, so the notice can be the way to it.1479 /// What the last finished export wrote, so the notice can be the way to it.
1476 /// Only the [`EXPORT_DONE`] line reads it -- any later notice has replaced1480 /// Only the [`EXPORT_DONE`] line reads it -- any later notice has replaced
1477 /// that text -- so a click never opens a file the bar is not naming.1481 /// that text -- so a click never opens a file the bar is not naming.
@@ -1625,7 +1629,7 @@ impl Player {
1625 // A state refusal is spoken: the thing exists and cannot happen1629 // A state refusal is spoken: the thing exists and cannot happen
1626 // *now*, which is exactly what a silent key press fails to say.1630 // *now*, which is exactly what a silent key press fails to say.
1627 Enable::No(why) => {1631 Enable::No(why) => {
1628- self.notice = Some(format!("{} — {why}", action.label()).into());1632+ self.notify_user(format!("{} — {why}", action.label()).into());
1629 cx.notify();1633 cx.notify();
1630 return;1634 return;
1631 }1635 }
@@ -1695,6 +1699,24 @@ impl Player {
1695 }1699 }
1696 }1700 }
1697 1701
1702+ /// Says something to the user. The one door: every message in this editor
1703+ /// comes through here, so "queued rather than overwritten" is a property of
1704+ /// the field and not of seventy call sites remembering to be polite.
1705+ ///
1706+ /// A repeat of what is already at the back is dropped -- holding a key that
1707+ /// refuses would otherwise fill the queue with one sentence, and the count
1708+ /// on the bar would be a count of how long the key was held.
1709+ fn notify_user(&mut self, message: SharedString) {
1710+ push_notice(&mut self.notices, message);
1711+ }
1712+
1713+ /// Answers the message on the bar and brings up the next one. Whether there
1714+ /// was one to answer, because a key that dismissed a notice owes a repaint
1715+ /// and a key that dismissed nothing does not.
1716+ fn dismiss_notice(&mut self) -> bool {
1717+ self.notices.pop_front().is_some()
1718+ }
1719+
1698 /// The magnet off and on again, in words: a snap that stops working1720 /// The magnet off and on again, in words: a snap that stops working
1699 /// silently reads as a bug, and one that starts working silently reads as1721 /// silently reads as a bug, and one that starts working silently reads as
1700 /// one too. The line goes with it -- nothing is being promised any more.1722 /// one too. The line goes with it -- nothing is being promised any more.
@@ -1702,7 +1724,7 @@ impl Player {
1702 self.snap = !self.snap;1724 self.snap = !self.snap;
1703 self.snap_cue = None;1725 self.snap_cue = None;
1704 self.ghost = None;1726 self.ghost = None;
1705- self.notice = Some(match self.snap {1727+ self.notify_user(match self.snap {
1706 true => "SNAP ON — drags land on clip edges, the playhead and the start".into(),1728 true => "SNAP ON — drags land on clip edges, the playhead and the start".into(),
1707 false => "SNAP OFF — drags land exactly where the hand leaves them".into(),1729 false => "SNAP OFF — drags land exactly where the hand leaves them".into(),
1708 });1730 });
@@ -1752,7 +1774,7 @@ impl Player {
1752 .as_ref()1774 .as_ref()
1753 .and_then(|session| sub_pick_name(session.subtitles(), self.sub_track))1775 .and_then(|session| sub_pick_name(session.subtitles(), self.sub_track))
1754 .unwrap_or_else(|| "nothing imported".to_string());1776 .unwrap_or_else(|| "nothing imported".to_string());
1755- self.notice = Some(1777+ self.notify_user(
1756 match self.subs_on {1778 match self.subs_on {
1757 true => format!("SUBTITLES ON — {label}"),1779 true => format!("SUBTITLES ON — {label}"),
1758 false => format!("SUBTITLES OFF — {label} is still on the timeline"),1780 false => format!("SUBTITLES OFF — {label} is still on the timeline"),
@@ -1880,7 +1902,7 @@ impl Player {
1880 fn select_under_playhead(&mut self, cx: &mut Context<Self>) {1902 fn select_under_playhead(&mut self, cx: &mut Context<Self>) {
1881 let under = self.under_playhead();1903 let under = self.under_playhead();
1882 let Some(&first) = under.first() else {1904 let Some(&first) = under.first() else {
1883- self.notice = Some("NOTHING UNDER THE PLAYHEAD — move it onto a clip first".into());1905+ self.notify_user("NOTHING UNDER THE PLAYHEAD — move it onto a clip first".into());
1884 cx.notify();1906 cx.notify();
1885 return;1907 return;
1886 };1908 };
@@ -1930,7 +1952,7 @@ impl Player {
1930 return;1952 return;
1931 }1953 }
1932 let Some(session) = &mut self.session else {1954 let Some(session) = &mut self.session else {
1933- self.notice = Some("no timeline to fit — open a file first".into());1955+ self.notify_user("no timeline to fit — open a file first".into());
1934 cx.notify();1956 cx.notify();
1935 return;1957 return;
1936 };1958 };
@@ -1939,7 +1961,7 @@ impl Player {
1939 .filter(|(lane, _)| lane.kind == LaneKind::Video)1961 .filter(|(lane, _)| lane.kind == LaneKind::Video)
1940 .or_else(|| session.video_clip_at(session.now()));1962 .or_else(|| session.video_clip_at(session.now()));
1941 let Some((lane, idx)) = target else {1963 let Some((lane, idx)) = target else {
1942- self.notice = Some("no clip under the playhead to fit".into());1964+ self.notify_user("no clip under the playhead to fit".into());
1943 cx.notify();1965 cx.notify();
1944 return;1966 return;
1945 };1967 };
@@ -1955,7 +1977,7 @@ impl Player {
1955 && session.set_fit(lane, idx, fit)1977 && session.set_fit(lane, idx, fit)
1956 {1978 {
1957 let (w, h) = session.resolution();1979 let (w, h) = session.resolution();
1958- self.notice = Some(format!("FIT POLICY: {} on {w}x{h}", fit_label(fit)).into());1980+ self.notify_user(format!("FIT POLICY: {} on {w}x{h}", fit_label(fit)).into());
1959 self.reset_after_reseek();1981 self.reset_after_reseek();
1960 }1982 }
1961 cx.notify();1983 cx.notify();
@@ -2005,7 +2027,7 @@ impl Player {
2005 return;2027 return;
2006 }2028 }
2007 let Some(session) = &mut self.session else {2029 let Some(session) = &mut self.session else {
2008- self.notice = Some("no timeline to resize — open a file first".into());2030+ self.notify_user("no timeline to resize — open a file first".into());
2009 cx.notify();2031 cx.notify();
2010 return;2032 return;
2011 };2033 };
@@ -2019,7 +2041,7 @@ impl Player {
2019 if let Some(session) = &mut self.session2041 if let Some(session) = &mut self.session
2020 && session.set_resolution(width, height)2042 && session.set_resolution(width, height)
2021 {2043 {
2022- self.notice = Some(format!("PROJECT: {width}x{height}").into());2044+ self.notify_user(format!("PROJECT: {width}x{height}").into());
2023 self.reset_after_reseek();2045 self.reset_after_reseek();
2024 }2046 }
2025 cx.notify();2047 cx.notify();
@@ -2036,7 +2058,7 @@ impl Player {
2036 && session.set_frame_rate(fps)2058 && session.set_frame_rate(fps)
2037 {2059 {
2038 self.fps = session.meta().frame_rate;2060 self.fps = session.meta().frame_rate;
2039- self.notice = Some(format!("PROJECT: {} fps", fps_label(fps)).into());2061+ self.notify_user(format!("PROJECT: {} fps", fps_label(fps)).into());
2040 self.reset_after_reseek();2062 self.reset_after_reseek();
2041 }2063 }
2042 cx.notify();2064 cx.notify();
@@ -2052,7 +2074,7 @@ impl Player {
2052 if let Some(session) = &mut self.session2074 if let Some(session) = &mut self.session
2053 && session.set_tone(preset)2075 && session.set_tone(preset)
2054 {2076 {
2055- self.notice = Some(format!("HDR: {} — affects HDR media", tone_label(preset)).into());2077+ self.notify_user(format!("HDR: {} — affects HDR media", tone_label(preset)).into());
2056 self.reset_after_reseek();2078 self.reset_after_reseek();
2057 }2079 }
2058 cx.notify();2080 cx.notify();
@@ -2118,7 +2140,7 @@ impl Player {
2118 return;2140 return;
2119 }2141 }
2120 let Some(session) = &self.session else {2142 let Some(session) = &self.session else {
2121- self.notice = Some("no timeline to grade — open a file first".into());2143+ self.notify_user("no timeline to grade — open a file first".into());
2122 cx.notify();2144 cx.notify();
2123 return;2145 return;
2124 };2146 };
@@ -2139,7 +2161,7 @@ impl Player {
2139 self.export_open = false;2161 self.export_open = false;
2140 self.context_menu = None;2162 self.context_menu = None;
2141 }2163 }
2142- None => self.notice = Some("no clip under the playhead to grade".into()),2164+ None => self.notify_user("no clip under the playhead to grade".into()),
2143 }2165 }
2144 cx.notify();2166 cx.notify();
2145 }2167 }
@@ -2250,7 +2272,7 @@ impl Player {
2250 return;2272 return;
2251 }2273 }
2252 let Some(session) = &self.session else {2274 let Some(session) = &self.session else {
2253- self.notice = Some("no timeline to re-time — open a file first".into());2275+ self.notify_user("no timeline to re-time — open a file first".into());
2254 cx.notify();2276 cx.notify();
2255 return;2277 return;
2256 };2278 };
@@ -2271,7 +2293,7 @@ impl Player {
2271 self.close_silence();2293 self.close_silence();
2272 self.context_menu = None;2294 self.context_menu = None;
2273 }2295 }
2274- None => self.notice = Some("no clip under the playhead to re-time".into()),2296+ None => self.notify_user("no clip under the playhead to re-time".into()),
2275 }2297 }
2276 cx.notify();2298 cx.notify();
2277 }2299 }
@@ -2319,7 +2341,7 @@ impl Player {
2319 };2341 };
2320 match wrote {2342 match wrote {
2321 Ok(()) => self.reset_after_reseek(),2343 Ok(()) => self.reset_after_reseek(),
2322- Err(e) => self.notice = Some(e.to_string().into()),2344+ Err(e) => self.notify_user(e.to_string().into()),
2323 }2345 }
2324 }2346 }
2325 cx.notify();2347 cx.notify();
@@ -2391,7 +2413,7 @@ impl Player {
2391 return;2413 return;
2392 }2414 }
2393 let Some(session) = &self.session else {2415 let Some(session) = &self.session else {
2394- self.notice = Some("no timeline to scan — open a file first".into());2416+ self.notify_user("no timeline to scan — open a file first".into());
2395 cx.notify();2417 cx.notify();
2396 return;2418 return;
2397 };2419 };
@@ -2415,7 +2437,7 @@ impl Player {
2415 return;2437 return;
2416 };2438 };
2417 if engine::is_image(&source.path) {2439 if engine::is_image(&source.path) {
2418- self.notice = Some(unscannable(lane, idx, &source.path).into());2440+ self.notify_user(unscannable(lane, idx, &source.path).into());
2419 cx.notify();2441 cx.notify();
2420 return;2442 return;
2421 }2443 }
@@ -2439,7 +2461,7 @@ impl Player {
2439 ScanPlan::Wait => {}2461 ScanPlan::Wait => {}
2440 }2462 }
2441 }2463 }
2442- None => self.notice = Some("no clip under the playhead to scan".into()),2464+ None => self.notify_user("no clip under the playhead to scan".into()),
2443 }2465 }
2444 cx.notify();2466 cx.notify();
2445 }2467 }
@@ -2585,13 +2607,13 @@ impl Player {
2585 // user knows which one it meant.2607 // user knows which one it meant.
2586 Ok(None) => {2608 Ok(None) => {
2587 if let Some((lane, idx)) = this.silence_open {2609 if let Some((lane, idx)) = this.silence_open {
2588- this.notice = Some(unscannable(lane, idx, &key.0).into());2610+ this.notify_user(unscannable(lane, idx, &key.0).into());
2589 }2611 }
2590 this.close_silence();2612 this.close_silence();
2591 }2613 }
2592 Err(e) => {2614 Err(e) => {
2593 this.close_silence();2615 this.close_silence();
2594- this.notice = Some(format!("SCAN FAILED: {e}").into());2616+ this.notify_user(format!("SCAN FAILED: {e}").into());
2595 }2617 }
2596 }2618 }
2597 cx.notify();2619 cx.notify();
@@ -2719,7 +2741,7 @@ impl Player {
2719 /// nothing.2741 /// nothing.
2720 fn previewed(&mut self) -> Option<(Vec<(u32, u32)>, Vec<Lane>)> {2742 fn previewed(&mut self) -> Option<(Vec<(u32, u32)>, Vec<Lane>)> {
2721 if self.silence_marks.is_empty() {2743 if self.silence_marks.is_empty() {
2722- self.notice = Some(2744+ self.notify_user(
2723 format!(2745 format!(
2724 "no silence under {:.0} dBFS lasting {:.2} s — raise the threshold or forgive less",2746 "no silence under {:.0} dBFS lasting {:.2} s — raise the threshold or forgive less",
2725 self.silence.threshold_db, self.silence.min_silence2747 self.silence.threshold_db, self.silence.min_silence
@@ -2771,7 +2793,7 @@ impl Player {
2771 // moves indexes (a delete, a paste, an undo).2793 // moves indexes (a delete, a paste, an undo).
2772 self.selected = None;2794 self.selected = None;
2773 self.reset_after_reseek();2795 self.reset_after_reseek();
2774- self.notice = Some(2796+ self.notify_user(
2775 format!(2797 format!(
2776 "{count} SILENCES CUT {reach} — {} shorter, {} takes it back",2798 "{count} SILENCES CUT {reach} — {} shorter, {} takes it back",
2777 secs_label(saved),2799 secs_label(saved),
@@ -2780,7 +2802,7 @@ impl Player {
2780 .into(),2802 .into(),
2781 );2803 );
2782 }2804 }
2783- Err(e) => self.notice = Some(e.to_string().into()),2805+ Err(e) => self.notify_user(e.to_string().into()),
2784 }2806 }
2785 cx.notify();2807 cx.notify();
2786 }2808 }
@@ -2810,7 +2832,7 @@ impl Player {
2810 // goes with them.2832 // goes with them.
2811 self.selected = None;2833 self.selected = None;
2812 self.reset_after_reseek();2834 self.reset_after_reseek();
2813- self.notice = Some(2835+ self.notify_user(
2814 format!(2836 format!(
2815 "{count} SILENCES AT {rate} {reach} — {} takes it back",2837 "{count} SILENCES AT {rate} {reach} — {} takes it back",
2816 self.keymap.display(ActionId::Undo)2838 self.keymap.display(ActionId::Undo)
@@ -2818,7 +2840,7 @@ impl Player {
2818 .into(),2840 .into(),
2819 );2841 );
2820 }2842 }
2821- Err(e) => self.notice = Some(e.to_string().into()),2843+ Err(e) => self.notify_user(e.to_string().into()),
2822 }2844 }
2823 cx.notify();2845 cx.notify();
2824 }2846 }
@@ -2926,7 +2948,7 @@ impl Player {
2926 _ => None,2948 _ => None,
2927 };2949 };
2928 if let Some(refusal) = refusal {2950 if let Some(refusal) = refusal {
2929- self.notice = Some(refusal.into());2951+ self.notify_user(refusal.into());
2930 cx.notify();2952 cx.notify();
2931 return;2953 return;
2932 }2954 }
@@ -3016,7 +3038,7 @@ impl Player {
3016 /// band that was just made. Refused rather than silently ignored at the cap.3038 /// band that was just made. Refused rather than silently ignored at the cap.
3017 fn add_band(&mut self, cx: &mut Context<Self>) {3039 fn add_band(&mut self, cx: &mut Context<Self>) {
3018 if self.eq_params.bands.len() >= EQ_BANDS_MAX {3040 if self.eq_params.bands.len() >= EQ_BANDS_MAX {
3019- self.notice = Some(3041+ self.notify_user(
3020 format!(3042 format!(
3021 "EQUALIZER FULL — {EQ_BANDS_MAX} bands is all this card holds; move one instead"3043 "EQUALIZER FULL — {EQ_BANDS_MAX} bands is all this card holds; move one instead"
3022 )3044 )
@@ -3035,7 +3057,7 @@ impl Player {
3035 /// is a card with nothing to edit, and flattening is what "off" means here.3057 /// is a card with nothing to edit, and flattening is what "off" means here.
3036 fn remove_band(&mut self, cx: &mut Context<Self>) {3058 fn remove_band(&mut self, cx: &mut Context<Self>) {
3037 if self.eq_params.bands.len() <= 1 {3059 if self.eq_params.bands.len() <= 1 {
3038- self.notice = Some("LAST BAND — flatten it instead (r), or close the card".into());3060+ self.notify_user("LAST BAND — flatten it instead (r), or close the card".into());
3039 cx.notify();3061 cx.notify();
3040 return;3062 return;
3041 }3063 }
@@ -3122,7 +3144,7 @@ impl Player {
3122 if session.regroup_at(session.now()) {3144 if session.regroup_at(session.now()) {
3123 self.selected = None;3145 self.selected = None;
3124 } else {3146 } else {
3125- self.notice = Some(3147+ self.notify_user(
3126 "NOTHING TO REGROUP — put the playhead where two clips meet, on frames that were cut apart"3148 "NOTHING TO REGROUP — put the playhead where two clips meet, on frames that were cut apart"
3127 .into(),3149 .into(),
3128 );3150 );
@@ -3142,12 +3164,13 @@ impl Player {
3142 match (&mut self.session, self.selected) {3164 match (&mut self.session, self.selected) {
3143 (Some(session), Some((lane, idx))) => {3165 (Some(session), Some((lane, idx))) => {
3144 if !session.ungroup(lane, idx) {3166 if !session.ungroup(lane, idx) {
3145- self.notice =3167+ self.notify_user(
3146- Some("NOTHING DETACHED — that clip is not grouped with another".into());3168+ "NOTHING DETACHED — that clip is not grouped with another".into(),
3169+ );
3147 }3170 }
3148 }3171 }
3149 (Some(_), None) => {3172 (Some(_), None) => {
3150- self.notice = Some("NOTHING DETACHED — click the take to take apart first".into())3173+ self.notify_user("NOTHING DETACHED — click the take to take apart first".into())
3151 }3174 }
3152 (None, _) => {}3175 (None, _) => {}
3153 }3176 }
@@ -3171,17 +3194,17 @@ impl Player {
3171 match (&mut self.session, self.selected, partner) {3194 match (&mut self.session, self.selected, partner) {
3172 (Some(session), Some((lane, idx)), Some((other, o_idx))) => {3195 (Some(session), Some((lane, idx)), Some((other, o_idx))) => {
3173 if let Err(e) = session.group(lane, idx, other, o_idx) {3196 if let Err(e) = session.group(lane, idx, other, o_idx) {
3174- self.notice = Some(format!("NOT GROUPED — {e}").into());3197+ self.notify_user(format!("NOT GROUPED — {e}").into());
3175 }3198 }
3176 }3199 }
3177 (Some(_), Some(_), None) => {3200 (Some(_), Some(_), None) => {
3178- self.notice = Some(3201+ self.notify_user(
3179 "NOTHING TO GROUP WITH — no clip on another track covers exactly these frames"3202 "NOTHING TO GROUP WITH — no clip on another track covers exactly these frames"
3180 .into(),3203 .into(),
3181 )3204 )
3182 }3205 }
3183 (Some(_), None, _) => {3206 (Some(_), None, _) => {
3184- self.notice = Some("NOTHING GROUPED — click one of the halves first".into())3207+ self.notify_user("NOTHING GROUPED — click one of the halves first".into())
3185 }3208 }
3186 (None, ..) => {}3209 (None, ..) => {}
3187 }3210 }
@@ -3211,7 +3234,7 @@ impl Player {
3211 _ => false,3234 _ => false,
3212 };3235 };
3213 if selected.is_some() && !deleted {3236 if selected.is_some() && !deleted {
3214- self.notice = Some("NOTHING DELETED — that clip is no longer there".into());3237+ self.notify_user("NOTHING DELETED — that clip is no longer there".into());
3215 }3238 }
3216 if deleted {3239 if deleted {
3217 self.reset_after_reseek();3240 self.reset_after_reseek();
@@ -3231,11 +3254,11 @@ impl Player {
3231 if session.lift_clip(lane, idx) {3254 if session.lift_clip(lane, idx) {
3232 self.reset_after_reseek();3255 self.reset_after_reseek();
3233 } else {3256 } else {
3234- self.notice = Some("NOTHING LIFTED — that half is no longer there".into());3257+ self.notify_user("NOTHING LIFTED — that half is no longer there".into());
3235 }3258 }
3236 }3259 }
3237 (Some(_), None) => {3260 (Some(_), None) => {
3238- self.notice = Some("NOTHING LIFTED — click the half to remove first".into())3261+ self.notify_user("NOTHING LIFTED — click the half to remove first".into())
3239 }3262 }
3240 (None, _) => {}3263 (None, _) => {}
3241 }3264 }
@@ -3516,7 +3539,7 @@ impl Player {
3516 // Everything else that could refuse (a clip that is not there)3539 // Everything else that could refuse (a clip that is not there)
3517 // cannot be dragged.3540 // cannot be dragged.
3518 false if from.kind != to.kind => {3541 false if from.kind != to.kind => {
3519- self.notice = Some(3542+ self.notify_user(
3520 format!(3543 format!(
3521 "NOT ON {} — that is a {kind} clip; drop it on a {lanes} lane",3544 "NOT ON {} — that is a {kind} clip; drop it on a {lanes} lane",
3522 to.label()3545 to.label()
@@ -3528,7 +3551,7 @@ impl Player {
3528 // says nothing.3551 // says nothing.
3529 false if from == to && start == was => {}3552 false if from == to && start == was => {}
3530 false => {3553 false => {
3531- self.notice = Some(3554+ self.notify_user(
3532 format!(3555 format!(
3533 "NOT MOVED — another clip already covers those frames on {}",3556 "NOT MOVED — another clip already covers those frames on {}",
3534 to.label()3557 to.label()
@@ -3909,7 +3932,7 @@ impl Player {
3909 // refused here -- where a file goes when nobody says is the engine's3932 // refused here -- where a file goes when nobody says is the engine's
3910 // choice, in `place_stream_at`, not one made twice here.3933 // choice, in `place_stream_at`, not one made twice here.
3911 if let Some(why) = onto.and_then(|lane| lane_refuses(path, lane)) {3934 if let Some(why) = onto.and_then(|lane| lane_refuses(path, lane)) {
3912- self.notice = Some(why.into());3935+ self.notify_user(why.into());
3913 cx.notify();3936 cx.notify();
3914 return;3937 return;
3915 }3938 }
@@ -3936,9 +3959,9 @@ impl Player {
3936 }3959 }
3937 // The engine's own words: a stream that cannot join this timeline3960 // The engine's own words: a stream that cannot join this timeline
3938 // says which property disagrees, exactly as a refused import does.3961 // says which property disagrees, exactly as a refused import does.
3939- Err(e) => self.notice = Some(format!("NOTHING ADDED — {e}").into()),3962+ Err(e) => self.notify_user(format!("NOTHING ADDED — {e}").into()),
3940 Ok(false) => {3963 Ok(false) => {
3941- self.notice = Some("NOTHING ADDED — that file could not be placed here".into())3964+ self.notify_user("NOTHING ADDED — that file could not be placed here".into())
3942 }3965 }
3943 }3966 }
3944 cx.notify();3967 cx.notify();
@@ -3999,7 +4022,7 @@ impl Player {
3999 Some(Err(e)) => format!("NOT REMOVED — {e}"),4022 Some(Err(e)) => format!("NOT REMOVED — {e}"),
4000 None => "NO TIMELINE — open a file first".to_string(),4023 None => "NO TIMELINE — open a file first".to_string(),
4001 };4024 };
4002- self.notice = Some(text.into());4025+ self.notify_user(text.into());
4003 cx.notify();4026 cx.notify();
4004 }4027 }
4005 4028
@@ -4279,7 +4302,7 @@ impl Player {
4279 Landed::Media(opened, place) => {4302 Landed::Media(opened, place) => {
4280 let text = self.install_media(path, opened, place);4303 let text = self.install_media(path, opened, place);
4281 eprintln!("{text}");4304 eprintln!("{text}");
4282- self.notice = Some(text.into());4305+ self.notify_user(text.into());
4283 cx.notify();4306 cx.notify();
4284 }4307 }
4285 Landed::Read(..) => unreachable!("matched above"),4308 Landed::Read(..) => unreachable!("matched above"),
@@ -4347,7 +4370,7 @@ impl Player {
4347 None => self.open_media(path, false, subs),4370 None => self.open_media(path, false, subs),
4348 };4371 };
4349 eprintln!("{text}");4372 eprintln!("{text}");
4350- self.notice = Some(text.into());4373+ self.notify_user(text.into());
4351 cx.notify();4374 cx.notify();
4352 }4375 }
4353 4376
@@ -4431,7 +4454,7 @@ impl Player {
4431 Ok(None) => {}4454 Ok(None) => {}
4432 Err(text) => {4455 Err(text) => {
4433 eprintln!("{text}");4456 eprintln!("{text}");
4434- this.notice = Some(text.into());4457+ this.notify_user(text.into());
4435 cx.notify();4458 cx.notify();
4436 }4459 }
4437 })4460 })
@@ -4456,7 +4479,7 @@ impl Player {
4456 if let Some(why) = self.enable(ActionId::AddSubtitleTrack, None).why() {4479 if let Some(why) = self.enable(ActionId::AddSubtitleTrack, None).why() {
4457 let text = format!("NO SUBTITLES ADDED — {why}");4480 let text = format!("NO SUBTITLES ADDED — {why}");
4458 eprintln!("{text}");4481 eprintln!("{text}");
4459- self.notice = Some(text.into());4482+ self.notify_user(text.into());
4460 cx.notify();4483 cx.notify();
4461 return;4484 return;
4462 }4485 }
@@ -4471,7 +4494,7 @@ impl Player {
4471 Ok(None) => {}4494 Ok(None) => {}
4472 Err(text) => {4495 Err(text) => {
4473 eprintln!("{text}");4496 eprintln!("{text}");
4474- this.notice = Some(text.into());4497+ this.notify_user(text.into());
4475 cx.notify();4498 cx.notify();
4476 }4499 }
4477 })4500 })
@@ -4495,7 +4518,7 @@ impl Player {
4495 self.landed_subtitles(path, None, cx);4518 self.landed_subtitles(path, None, cx);
4496 return;4519 return;
4497 }4520 }
4498- self.notice = Some(format!("READING {} for subtitles…", file_name(path)).into());4521+ self.notify_user(format!("READING {} for subtitles…", file_name(path)).into());
4499 let parsed = cx.background_executor().spawn({4522 let parsed = cx.background_executor().spawn({
4500 let path = path.to_path_buf();4523 let path = path.to_path_buf();
4501 async move { engine::PlaybackSession::parse_subtitles(&path) }4524 async move { engine::PlaybackSession::parse_subtitles(&path) }
@@ -4553,7 +4576,7 @@ impl Player {
4553 None => "NO SUBTITLES ADDED — open a file for them to run against first".to_string(),4576 None => "NO SUBTITLES ADDED — open a file for them to run against first".to_string(),
4554 };4577 };
4555 eprintln!("{text}");4578 eprintln!("{text}");
4556- self.notice = Some(text.into());4579+ self.notify_user(text.into());
4557 cx.notify();4580 cx.notify();
4558 }4581 }
4559 4582
@@ -4576,7 +4599,7 @@ impl Player {
4576 if let Some(why) = self.enable(ActionId::RemoveSubtitleTrack, None).why() {4599 if let Some(why) = self.enable(ActionId::RemoveSubtitleTrack, None).why() {
4577 let text = format!("NO SUBTITLES REMOVED — {why}");4600 let text = format!("NO SUBTITLES REMOVED — {why}");
4578 eprintln!("{text}");4601 eprintln!("{text}");
4579- self.notice = Some(text.into());4602+ self.notify_user(text.into());
4580 cx.notify();4603 cx.notify();
4581 return;4604 return;
4582 }4605 }
@@ -4609,7 +4632,7 @@ impl Player {
4609 None => "NO SUBTITLES REMOVED — open a file first".to_string(),4632 None => "NO SUBTITLES REMOVED — open a file first".to_string(),
4610 };4633 };
4611 eprintln!("{text}");4634 eprintln!("{text}");
4612- self.notice = Some(text.into());4635+ self.notify_user(text.into());
4613 cx.notify();4636 cx.notify();
4614 }4637 }
4615 4638
@@ -4672,7 +4695,7 @@ impl Player {
4672 Err(e) => format!("OPEN FAILED: {e}"),4695 Err(e) => format!("OPEN FAILED: {e}"),
4673 };4696 };
4674 eprintln!("{text}");4697 eprintln!("{text}");
4675- self.notice = Some(text.into());4698+ self.notify_user(text.into());
4676 cx.notify();4699 cx.notify();
4677 }4700 }
4678 4701
@@ -4689,7 +4712,7 @@ impl Player {
4689 None => "NOTHING TO SAVE — open a file first".to_string(),4712 None => "NOTHING TO SAVE — open a file first".to_string(),
4690 };4713 };
4691 eprintln!("{text}");4714 eprintln!("{text}");
4692- self.notice = Some(text.into());4715+ self.notify_user(text.into());
4693 cx.notify();4716 cx.notify();
4694 }4717 }
4695 4718
@@ -4704,7 +4727,7 @@ impl Player {
4704 match &mut self.session {4727 match &mut self.session {
4705 Some(session) => {4728 Some(session) => {
4706 let lane = session.add_lane(kind);4729 let lane = session.add_lane(kind);
4707- self.notice = Some(4730+ self.notify_user(
4708 format!(4731 format!(
4709 "{} ADDED — drag a clip onto it, {} takes it back",4732 "{} ADDED — drag a clip onto it, {} takes it back",
4710 lane.label(),4733 lane.label(),
@@ -4713,7 +4736,7 @@ impl Player {
4713 .into(),4736 .into(),
4714 );4737 );
4715 }4738 }
4716- None => self.notice = Some("NO TRACK ADDED — open a file first".into()),4739+ None => self.notify_user("NO TRACK ADDED — open a file first".into()),
4717 }4740 }
4718 cx.notify();4741 cx.notify();
4719 }4742 }
@@ -4752,7 +4775,7 @@ impl Player {
4752 Some(Err(e)) => format!("NO TRACK REMOVED — {e}"),4775 Some(Err(e)) => format!("NO TRACK REMOVED — {e}"),
4753 None => "NO TRACK REMOVED — open a file first".to_string(),4776 None => "NO TRACK REMOVED — open a file first".to_string(),
4754 };4777 };
4755- self.notice = Some(text.into());4778+ self.notify_user(text.into());
4756 cx.notify();4779 cx.notify();
4757 }4780 }
4758 4781
@@ -4770,7 +4793,7 @@ impl Player {
4770 match last {4793 match last {
4771 Some(lane) => self.remove_lane(lane, cx),4794 Some(lane) => self.remove_lane(lane, cx),
4772 None => {4795 None => {
4773- self.notice = Some("NO TRACK REMOVED — open a file first".into());4796+ self.notify_user("NO TRACK REMOVED — open a file first".into());
4774 cx.notify();4797 cx.notify();
4775 }4798 }
4776 }4799 }
@@ -4804,7 +4827,7 @@ impl Player {
4804 if !chord.bindable() {4827 if !chord.bindable() {
4805 let text = format!("THAT KEY CANNOT BE BOUND — {}", chord.pretty());4828 let text = format!("THAT KEY CANNOT BE BOUND — {}", chord.pretty());
4806 eprintln!("{text}");4829 eprintln!("{text}");
4807- self.notice = Some(text.into());4830+ self.notify_user(text.into());
4808 return;4831 return;
4809 }4832 }
4810 let text = match self.keymap.rebind_action(action, chord.clone()) {4833 let text = match self.keymap.rebind_action(action, chord.clone()) {
@@ -4821,7 +4844,7 @@ impl Player {
4821 Err(holder) => format!("ALREADY BOUND — {} is {}", chord.pretty(), holder.label()),4844 Err(holder) => format!("ALREADY BOUND — {} is {}", chord.pretty(), holder.label()),
4822 };4845 };
4823 eprintln!("{text}");4846 eprintln!("{text}");
4824- self.notice = Some(text.into());4847+ self.notify_user(text.into());
4825 }4848 }
4826 4849
4827 /// Seeks to where the pointer sits along the ruler. `commit` is the press4850 /// Seeks to where the pointer sits along the ruler. `commit` is the press
@@ -4889,7 +4912,7 @@ impl Player {
4889 if nothing_to_play(self.session.as_ref()) {4912 if nothing_to_play(self.session.as_ref()) {
4890 match self.session.as_mut().filter(|s| s.is_playing()) {4913 match self.session.as_mut().filter(|s| s.is_playing()) {
4891 Some(session) => session.pause(),4914 Some(session) => session.pause(),
4892- None => self.notice = Some(NOTHING_TO_PLAY.into()),4915+ None => self.notify_user(NOTHING_TO_PLAY.into()),
4893 }4916 }
4894 cx.notify();4917 cx.notify();
4895 return;4918 return;
@@ -4932,7 +4955,7 @@ impl Player {
4932 // Nothing to write out, and a refusal rather than a card about it: the4955 // Nothing to write out, and a refusal rather than a card about it: the
4933 // window is empty and the export path is not even chosen yet.4956 // window is empty and the export path is not even chosen yet.
4934 if self.session.is_none() {4957 if self.session.is_none() {
4935- self.notice = Some("NOTHING TO EXPORT — open a file first".into());4958+ self.notify_user("NOTHING TO EXPORT — open a file first".into());
4936 cx.notify();4959 cx.notify();
4937 return;4960 return;
4938 }4961 }
@@ -4957,7 +4980,7 @@ impl Player {
4957 .as_ref()4980 .as_ref()
4958 .and_then(|session| format_refusal(session, format))4981 .and_then(|session| format_refusal(session, format))
4959 {4982 {
4960- self.notice = Some(format!("NOT {} — {why}", format_label(format)).into());4983+ self.notify_user(format!("NOT {} — {why}", format_label(format)).into());
4961 return;4984 return;
4962 }4985 }
4963 self.format = format;4986 self.format = format;
@@ -4977,7 +5000,7 @@ impl Player {
4977 /// looking broken.5000 /// looking broken.
4978 fn cycle_quality(&mut self) {5001 fn cycle_quality(&mut self) {
4979 if let Some(why) = bitrate_refusal(self.format) {5002 if let Some(why) = bitrate_refusal(self.format) {
4980- self.notice = Some(why.into());5003+ self.notify_user(why.into());
4981 return;5004 return;
4982 }5005 }
4983 let at = Quality::ALL5006 let at = Quality::ALL
@@ -4994,7 +5017,7 @@ impl Player {
4994 /// card looking broken.5017 /// card looking broken.
4995 fn cycle_audio_kbps(&mut self) {5018 fn cycle_audio_kbps(&mut self) {
4996 if let Some(why) = self.audio_rate_refusal() {5019 if let Some(why) = self.audio_rate_refusal() {
4997- self.notice = Some(why.into());5020+ self.notify_user(why.into());
4998 return;5021 return;
4999 }5022 }
5000 self.audio_kbps = next_audio_kbps(self.audio_kbps);5023 self.audio_kbps = next_audio_kbps(self.audio_kbps);
@@ -5055,7 +5078,7 @@ impl Player {
5055 Ok(None) => {}5078 Ok(None) => {}
5056 Err(text) => {5079 Err(text) => {
5057 eprintln!("{text}");5080 eprintln!("{text}");
5058- this.notice = Some(text.into());5081+ this.notify_user(text.into());
5059 }5082 }
5060 }5083 }
5061 cx.notify();5084 cx.notify();
@@ -5123,7 +5146,7 @@ impl Player {
5123 // calls for the *estimate* and which nothing else needs a subtitle for.5146 // calls for the *estimate* and which nothing else needs a subtitle for.
5124 settings.subtitles = self.export_subs();5147 settings.subtitles = self.export_subs();
5125 let Some(session) = &mut self.session else {5148 let Some(session) = &mut self.session else {
5126- self.notice = Some("NOTHING TO EXPORT — open a file first".into());5149+ self.notify_user("NOTHING TO EXPORT — open a file first".into());
5127 cx.notify();5150 cx.notify();
5128 return;5151 return;
5129 };5152 };
@@ -5133,7 +5156,7 @@ impl Player {
5133 // that is not this button cannot get past it either. Two fences on5156 // that is not this button cannot get past it either. Two fences on
5134 // purpose: this one is the one with a keystroke to blame.5157 // purpose: this one is the one with a keystroke to blame.
5135 if session.is_empty() {5158 if session.is_empty() {
5136- self.notice = Some("NOTHING TO EXPORT — the timeline is empty".into());5159+ self.notify_user("NOTHING TO EXPORT — the timeline is empty".into());
5137 cx.notify();5160 cx.notify();
5138 return;5161 return;
5139 }5162 }
@@ -5142,7 +5165,7 @@ impl Player {
5142 // edit away -- so the button asks again rather than starting a worker5165 // edit away -- so the button asks again rather than starting a worker
5143 // that will only settle with the same refusal minutes later.5166 // that will only settle with the same refusal minutes later.
5144 if let Some(why) = format_refusal(session, self.format) {5167 if let Some(why) = format_refusal(session, self.format) {
5145- self.notice = Some(format!("NOT EXPORTED — {why}").into());5168+ self.notify_user(format!("NOT EXPORTED — {why}").into());
5146 cx.notify();5169 cx.notify();
5147 return;5170 return;
5148 }5171 }
@@ -5202,7 +5225,7 @@ impl Player {
5202 Err(e) => format!("EXPORT FAILED: {e}"),5225 Err(e) => format!("EXPORT FAILED: {e}"),
5203 };5226 };
5204 eprintln!("{text}");5227 eprintln!("{text}");
5205- self.notice = Some(text.into());5228+ self.notify_user(text.into());
5206 }5229 }
5207 }5230 }
5208 5231
@@ -5293,11 +5316,12 @@ impl Render for Player {
5293 {5316 {
5294 return;5317 return;
5295 }5318 }
5296- // Any key retires the last message, whatever it was -- and owes5319+ // Any key answers the message on the bar and brings the next of
5320+ // them up, whatever it was -- and owes
5297 // the repaint itself: a notice no longer keeps the render loop5321 // the repaint itself: a notice no longer keeps the render loop
5298 // alive, and the arms below that do notify are not all of them5322 // alive, and the arms below that do notify are not all of them
5299 // (an unbound key, or the copy chord, changes nothing else).5323 // (an unbound key, or the copy chord, changes nothing else).
5300- if this.notice.take().is_some() {5324+ if this.dismiss_notice() {
5301 cx.notify();5325 cx.notify();
5302 }5326 }
5303 // A row is waiting for a stroke, and while it is, that stroke is5327 // A row is waiting for a stroke, and while it is, that stroke is
@@ -6116,6 +6140,28 @@ fn file_name(path: &std::path::Path) -> String {
6116 )6140 )
6117 }6141 }
6118 6142
6143+/// How many messages wait behind the one on the bar before the oldest is
6144+/// dropped. A queue with no ceiling is a way for a stuck loop to eat the heap;
6145+/// eight is more than a user will ever answer in a row.
6146+const NOTICES_MAX: usize = 8;
6147+
6148+/// The whole of the queue's policy, where it can be read at once and tested
6149+/// without a window: dedupe against the back, a ceiling, oldest out first.
6150+/// [`Player::notify_user`] is the door every message comes through; this is what
6151+/// the door does.
6152+fn push_notice(notices: &mut std::collections::VecDeque<SharedString>, message: SharedString) {
6153+ // A repeat of what is already at the back is dropped -- holding a key that
6154+ // refuses would otherwise fill the queue with one sentence, and the count on
6155+ // the bar would be a count of how long the key was held.
6156+ if notices.back() == Some(&message) {
6157+ return;
6158+ }
6159+ if notices.len() >= NOTICES_MAX {
6160+ notices.pop_front();
6161+ }
6162+ notices.push_back(message);
6163+}
6164+
6119 /// The tail an open/load notice grows when the file has sound the engine cannot6165 /// The tail an open/load notice grows when the file has sound the engine cannot
6120 /// decode: it plays perfectly, in silence, and that is the one thing the window6166 /// decode: it plays perfectly, in silence, and that is the one thing the window
6121 /// would otherwise never say (the engine's own word for it, verbatim).6167 /// would otherwise never say (the engine's own word for it, verbatim).
@@ -9510,7 +9556,8 @@ mod tests {
9510 marked, menu_at, menu_items, menu_rows_h, next_audio_kbps, next_container, normalise, nothing_to_play, panel_h, project_path,9556 marked, menu_at, menu_items, menu_rows_h, next_audio_kbps, next_container, normalise, nothing_to_play, panel_h, project_path,
9511 retarget, row_enable, row_items, scrub_due, secs_label, show_label, silence_rate, size_label, snap_cue, snap_marks, snapped,9557 retarget, row_enable, row_items, scrub_due, secs_label, show_label, silence_rate, size_label, snap_cue, snap_marks, snapped,
9512 SUB_PLAN_CHARS, source_tint, span_partner, speed_at, sub_pick_after_removal, subtitle_plan, summary_head, summary_tail, timecode, transport,9558 SUB_PLAN_CHARS, source_tint, span_partner, speed_at, sub_pick_after_removal, subtitle_plan, summary_head, summary_tail, timecode, transport,
9513- typed, unseen_paths, unseen_sources,9559+ EXPORT_DONE, NOTICES_MAX, STATUS_ERROR, STATUS_SUCCESS, STATUS_WARNING, notice_tone,
9560+ push_notice, typed, unseen_paths, unseen_sources,
9514 whole_take, window_title,9561 whole_take, window_title,
9515 };9562 };
9516 use super::{9563 use super::{
@@ -9566,6 +9613,7 @@ mod tests {
9566 fn ui_source() -> String {9613 fn ui_source() -> String {
9567 [9614 [
9568 include_str!("main.rs").split("#[cfg(test)]").next().unwrap(),9615 include_str!("main.rs").split("#[cfg(test)]").next().unwrap(),
9616+ include_str!("ui/theme.rs"),
9569 include_str!("ui/toolbar.rs"),9617 include_str!("ui/toolbar.rs"),
9570 include_str!("ui/inspector.rs"),9618 include_str!("ui/inspector.rs"),
9571 include_str!("ui/timeline.rs"),9619 include_str!("ui/timeline.rs"),
@@ -14279,6 +14327,46 @@ mod tests {
14279 assert!(stray.is_empty(), "colour written outside the theme: {stray:?}");14327 assert!(stray.is_empty(), "colour written outside the theme: {stray:?}");
14280 }14328 }
14281 14329
14330+ /// The failure a user never learns about is the one that was answered by
14331+ /// another failure: two imports failing back to back are two messages, in
14332+ /// the order they happened, and the second does not overwrite the first
14333+ /// before a frame has drawn it.
14334+ #[test]
14335+ fn a_second_message_queues_behind_the_first_instead_of_erasing_it() {
14336+ let mut q = std::collections::VecDeque::new();
14337+ push_notice(&mut q, "NOTHING ADDED — no video stream".into());
14338+ push_notice(&mut q, "NOTHING ADDED — the file is not there".into());
14339+ assert_eq!(q.len(), 2);
14340+ assert_eq!(q.front().map(|n: &gpui::SharedString| n.as_ref()), Some("NOTHING ADDED — no video stream"));
14341+
14342+ // A held key that refuses says its one sentence once: the count on the
14343+ // bar is a count of messages, not of how long the key was held.
14344+ push_notice(&mut q, "NOTHING ADDED — the file is not there".into());
14345+ assert_eq!(q.len(), 2);
14346+
14347+ // ...and the ceiling drops the oldest rather than the newest: the thing
14348+ // that just happened is the thing worth reading.
14349+ for i in 0..NOTICES_MAX + 3 {
14350+ push_notice(&mut q, format!("SCAN FAILED: {i}").into());
14351+ }
14352+ assert_eq!(q.len(), NOTICES_MAX);
14353+ assert_eq!(q.back().map(|n: &gpui::SharedString| n.as_ref()), Some("SCAN FAILED: 10"));
14354+
14355+ // Answering the bar brings the next one up, oldest first.
14356+ let front = q.pop_front();
14357+ assert_ne!(front, q.front().cloned());
14358+ }
14359+
14360+ /// The bar colours itself off the words the message already opens with, so
14361+ /// the tone cannot disagree with the sentence it labels.
14362+ #[test]
14363+ fn a_message_wears_the_colour_its_own_words_say() {
14364+ assert_eq!(notice_tone("SCAN FAILED: no audio"), STATUS_ERROR);
14365+ assert_eq!(notice_tone(&format!("{EXPORT_DONE}out.mp4")), STATUS_SUCCESS);
14366+ assert_eq!(notice_tone("NOTHING DETACHED — not grouped"), STATUS_WARNING);
14367+ assert_eq!(notice_tone("SNAP ON"), ACCENT_PRIMARY);
14368+ }
14369+
14282 /// The cards are sections of the inspector, not sheets over the timeline:14370 /// The cards are sections of the inspector, not sheets over the timeline:
14283 /// adjusting a clip must never hide the clip. Structural, because that is14371 /// adjusting a clip must never hide the clip. Structural, because that is
14284 /// where the rule lives -- a card rendered from the root again would be an14372 /// where the rule lives -- a card rendered from the root again would be an
@@ -15382,7 +15470,7 @@ fn main() {
15382 // there was anything to pick.15470 // there was anything to pick.
15383 format: Format::default(),15471 format: Format::default(),
15384 rebinding: None,15472 rebinding: None,
15385- notice: notice.clone().map(SharedString::from),15473+ notices: notice.clone().map(SharedString::from).into_iter().collect(),
15386 exported: None,15474 exported: None,
15387 // The whole of argv, waiting for the first repaint to start15475 // The whole of argv, waiting for the first repaint to start
15388 // it: the window is up before a byte of it is read.15476 // it: the window is up before a byte of it is read.
crates/app/src/ui/cards.rsmodified+2 -2
@@ -473,7 +473,7 @@ impl Player {
473 .px(px(6.))473 .px(px(6.))
474 .text_size(px(11.))474 .text_size(px(11.))
475 .text_color(rgb(FG_SECONDARY))475 .text_color(rgb(FG_SECONDARY))
476- .child(match (&self.mbps_edit, &self.notice) {476+ .child(match (&self.mbps_edit, self.notices.front()) {
477 // A field being typed into says so here as477 // A field being typed into says so here as
478 // well as in its row: this line is outside478 // well as in its row: this line is outside
479 // the scrolling list and on screen at every479 // the scrolling list and on screen at every
@@ -775,7 +775,7 @@ impl Player {
775 .px(px(6.))775 .px(px(6.))
776 .text_size(px(11.))776 .text_size(px(11.))
777 .text_color(rgb(FG_SECONDARY))777 .text_color(rgb(FG_SECONDARY))
778- .child(self.notice.clone().unwrap_or_else(|| {778+ .child(self.notices.front().cloned().unwrap_or_else(|| {
779 "drag a handle, or a digit picks a band — ←→ moves it, ↑↓ its gain, shift+←→ its width; a adds, x removes, f flattens it, r all, s spectrum; a click away or esc closes".into()779 "drag a handle, or a digit picks a band — ←→ moves it, ↑↓ its gain, shift+←→ its width; a adds, x removes, f flattens it, r all, s spectrum; a click away or esc closes".into()
780 })),780 })),
781 )781 )
crates/app/src/ui/overlays.rsmodified+23 -7
@@ -113,17 +113,27 @@ impl Player {
113 /// now on disk, so the same click that retires it shows that file in the113 /// now on disk, so the same click that retires it shows that file in the
114 /// desktop's file manager.114 /// desktop's file manager.
115 pub(crate) fn notice_bar(&self, cx: &mut Context<Self>) -> Option<impl IntoElement> {115 pub(crate) fn notice_bar(&self, cx: &mut Context<Self>) -> Option<impl IntoElement> {
116- let notice = self.notice.clone()?;116+ let notice = self.notices.front().cloned()?;
117 // The path travels with the text it was written for: a later notice117 // The path travels with the text it was written for: a later notice
118 // holds the bar and the click is a plain dismissal again.118 // holds the bar and the click is a plain dismissal again.
119 let exported = self119 let exported = self
120 .exported120 .exported
121 .clone()121 .clone()
122 .filter(|_| notice.starts_with(EXPORT_DONE));122 .filter(|_| notice.starts_with(EXPORT_DONE));
123- let hint = match exported {123+ // How many are waiting behind this one, said out loud: a queue nobody is
124- Some(_) => "click — open file location",124+ // told about is a queue whose second message reads as the first one
125- None => "click or press any key to dismiss",125+ // failing to go away.
126+ let behind = self.notices.len() - 1;
127+ let hint = match (exported.is_some(), behind) {
128+ (true, _) => "click — open file location".to_string(),
129+ (false, 0) => "click or press any key to dismiss".to_string(),
130+ (false, 1) => "click or press any key — 1 more message behind this".to_string(),
131+ (false, n) => format!("click or press any key — {n} more messages behind this"),
126 };132 };
133+ // What the message *is*, by colour, before it is read: the words the
134+ // editor shouts a failure in are the ones it opens with, so the bar can
135+ // colour itself off the same text every one of them already carries.
136+ let tone = notice_tone(&notice);
127 Some(137 Some(
128 div()138 div()
129 .id("notice")139 .id("notice")
@@ -142,6 +152,11 @@ impl Player {
142 .px(px(12.))152 .px(px(12.))
143 .py(px(6.))153 .py(px(6.))
144 .bg(rgb(BG_RAISED))154 .bg(rgb(BG_RAISED))
155+ // The tone is a stripe down the leading edge rather than the
156+ // whole bar's colour: a full red bar at every refusal is an
157+ // alarm, and most of these are answers.
158+ .border_l(px(3.))
159+ .border_color(rgb(tone))
145 .cursor_pointer()160 .cursor_pointer()
146 .hover(|s| s.bg(rgb(BG_HOVER)))161 .hover(|s| s.bg(rgb(BG_HOVER)))
147 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {162 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
@@ -152,7 +167,7 @@ impl Player {
152 .spawn(async move { show_in_file_manager(&path) })167 .spawn(async move { show_in_file_manager(&path) })
153 .detach();168 .detach();
154 }169 }
155- this.notice = None;170+ this.dismiss_notice();
156 cx.notify();171 cx.notify();
157 }))172 }))
158 .child(div().flex_1().min_w(px(0.)).child(notice))173 .child(div().flex_1().min_w(px(0.)).child(notice))
@@ -371,8 +386,9 @@ impl Player {
371 .text_size(px(11.))386 .text_size(px(11.))
372 .text_color(rgb(FG_SECONDARY))387 .text_color(rgb(FG_SECONDARY))
373 .child(388 .child(
374- self.notice389+ self.notices
375- .clone()390+ .front()
391+ .cloned()
376 .unwrap_or_else(|| {392 .unwrap_or_else(|| {
377 "click an action to do it · click its key to change it"393 "click an action to do it · click its key to change it"
378 .into()394 .into()
crates/app/src/ui/theme.rsmodified+22 -0
@@ -84,6 +84,28 @@ pub const STATUS_ERROR: u32 = 0xef4444;
84 pub const STATUS_WARNING: u32 = 0xf59e0b;84 pub const STATUS_WARNING: u32 = 0xf59e0b;
85 pub const STATUS_SUCCESS: u32 = 0x34d399;85 pub const STATUS_SUCCESS: u32 = 0x34d399;
86 pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY;86 pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY;
87+/// Which of the feedback colours a message wears. Read off the words rather
88+/// than carried alongside them: every message in this editor already opens with
89+/// what it is ("EXPORT DONE", "SCAN FAILED", "NOTHING DETACHED"), and a second
90+/// `tone` argument at seventy call sites is seventy chances to disagree with the
91+/// sentence it labels.
92+///
93+/// ponytail: prefix matching, so a message worded outside these families reads
94+/// as neutral rather than wrong. Ceiling: a `Notice { text, tone }` struct the
95+/// day a message needs a colour its own words do not say.
96+pub fn notice_tone(message: &str) -> u32 {
97+ let has = |word: &str| message.contains(word);
98+ if has("FAILED") || has("ERROR") || has("REFUSED") || has("CANNOT") || has("COULD NOT") {
99+ STATUS_ERROR
100+ } else if message.starts_with(crate::EXPORT_DONE) || has("SAVED") || has("DONE") {
101+ STATUS_SUCCESS
102+ } else if has("NOTHING") || has("NO ") || has("EMPTY") {
103+ STATUS_WARNING
104+ } else {
105+ ACCENT_PRIMARY
106+ }
107+}
108+
87 /// The mirror of [`BG_SELECTED`]: a drop the lane will not take, tinting the109 /// The mirror of [`BG_SELECTED`]: a drop the lane will not take, tinting the
88 /// shadow the drag draws so a refusal is seen before the release.110 /// shadow the drag draws so a refusal is seen before the release.
89 pub const DROP_REFUSE: u32 = 0x8f2740;111 pub const DROP_REFUSE: u32 = 0x8f2740;