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 {
14681468 /// The action whose row is waiting for a stroke. The next key that is
14691469 /// neither escape nor a lone modifier becomes the whole of what reaches it.
14701470 rebinding: Option<ActionId>,
1471- /// What the last file action had to say. Holds its own bar above the panel
1472- /// until it is answered -- any key retires it, so does a click on it -- so a
1473- /// failure is read in full instead of blinking past.
1474- notice: Option<SharedString>,
1471+ /// What the file actions have had to say, oldest first. A *queue* and not a
1472+ /// slot: two imports that fail back to back used to be one message, because
1473+ /// the second overwrote the first before a frame had drawn it -- the failure
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>,
14751479 /// What the last finished export wrote, so the notice can be the way to it.
14761480 /// Only the [`EXPORT_DONE`] line reads it -- any later notice has replaced
14771481 /// that text -- so a click never opens a file the bar is not naming.
@@ -1625,7 +1629,7 @@ impl Player {
16251629 // A state refusal is spoken: the thing exists and cannot happen
16261630 // *now*, which is exactly what a silent key press fails to say.
16271631 Enable::No(why) => {
1628- self.notice = Some(format!("{} — {why}", action.label()).into());
1632+ self.notify_user(format!("{} — {why}", action.label()).into());
16291633 cx.notify();
16301634 return;
16311635 }
@@ -1695,6 +1699,24 @@ impl Player {
16951699 }
16961700 }
16971701
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+
16981720 /// The magnet off and on again, in words: a snap that stops working
16991721 /// silently reads as a bug, and one that starts working silently reads as
17001722 /// one too. The line goes with it -- nothing is being promised any more.
@@ -1702,7 +1724,7 @@ impl Player {
17021724 self.snap = !self.snap;
17031725 self.snap_cue = None;
17041726 self.ghost = None;
1705- self.notice = Some(match self.snap {
1727+ self.notify_user(match self.snap {
17061728 true => "SNAP ON — drags land on clip edges, the playhead and the start".into(),
17071729 false => "SNAP OFF — drags land exactly where the hand leaves them".into(),
17081730 });
@@ -1752,7 +1774,7 @@ impl Player {
17521774 .as_ref()
17531775 .and_then(|session| sub_pick_name(session.subtitles(), self.sub_track))
17541776 .unwrap_or_else(|| "nothing imported".to_string());
1755- self.notice = Some(
1777+ self.notify_user(
17561778 match self.subs_on {
17571779 true => format!("SUBTITLES ON — {label}"),
17581780 false => format!("SUBTITLES OFF — {label} is still on the timeline"),
@@ -1880,7 +1902,7 @@ impl Player {
18801902 fn select_under_playhead(&mut self, cx: &mut Context<Self>) {
18811903 let under = self.under_playhead();
18821904 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());
18841906 cx.notify();
18851907 return;
18861908 };
@@ -1930,7 +1952,7 @@ impl Player {
19301952 return;
19311953 }
19321954 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());
19341956 cx.notify();
19351957 return;
19361958 };
@@ -1939,7 +1961,7 @@ impl Player {
19391961 .filter(|(lane, _)| lane.kind == LaneKind::Video)
19401962 .or_else(|| session.video_clip_at(session.now()));
19411963 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());
19431965 cx.notify();
19441966 return;
19451967 };
@@ -1955,7 +1977,7 @@ impl Player {
19551977 && session.set_fit(lane, idx, fit)
19561978 {
19571979 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());
19591981 self.reset_after_reseek();
19601982 }
19611983 cx.notify();
@@ -2005,7 +2027,7 @@ impl Player {
20052027 return;
20062028 }
20072029 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());
20092031 cx.notify();
20102032 return;
20112033 };
@@ -2019,7 +2041,7 @@ impl Player {
20192041 if let Some(session) = &mut self.session
20202042 && session.set_resolution(width, height)
20212043 {
2022- self.notice = Some(format!("PROJECT: {width}x{height}").into());
2044+ self.notify_user(format!("PROJECT: {width}x{height}").into());
20232045 self.reset_after_reseek();
20242046 }
20252047 cx.notify();
@@ -2036,7 +2058,7 @@ impl Player {
20362058 && session.set_frame_rate(fps)
20372059 {
20382060 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());
20402062 self.reset_after_reseek();
20412063 }
20422064 cx.notify();
@@ -2052,7 +2074,7 @@ impl Player {
20522074 if let Some(session) = &mut self.session
20532075 && session.set_tone(preset)
20542076 {
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());
20562078 self.reset_after_reseek();
20572079 }
20582080 cx.notify();
@@ -2118,7 +2140,7 @@ impl Player {
21182140 return;
21192141 }
21202142 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());
21222144 cx.notify();
21232145 return;
21242146 };
@@ -2139,7 +2161,7 @@ impl Player {
21392161 self.export_open = false;
21402162 self.context_menu = None;
21412163 }
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()),
21432165 }
21442166 cx.notify();
21452167 }
@@ -2250,7 +2272,7 @@ impl Player {
22502272 return;
22512273 }
22522274 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());
22542276 cx.notify();
22552277 return;
22562278 };
@@ -2271,7 +2293,7 @@ impl Player {
22712293 self.close_silence();
22722294 self.context_menu = None;
22732295 }
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()),
22752297 }
22762298 cx.notify();
22772299 }
@@ -2319,7 +2341,7 @@ impl Player {
23192341 };
23202342 match wrote {
23212343 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()),
23232345 }
23242346 }
23252347 cx.notify();
@@ -2391,7 +2413,7 @@ impl Player {
23912413 return;
23922414 }
23932415 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());
23952417 cx.notify();
23962418 return;
23972419 };
@@ -2415,7 +2437,7 @@ impl Player {
24152437 return;
24162438 };
24172439 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());
24192441 cx.notify();
24202442 return;
24212443 }
@@ -2439,7 +2461,7 @@ impl Player {
24392461 ScanPlan::Wait => {}
24402462 }
24412463 }
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()),
24432465 }
24442466 cx.notify();
24452467 }
@@ -2585,13 +2607,13 @@ impl Player {
25852607 // user knows which one it meant.
25862608 Ok(None) => {
25872609 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());
25892611 }
25902612 this.close_silence();
25912613 }
25922614 Err(e) => {
25932615 this.close_silence();
2594- this.notice = Some(format!("SCAN FAILED: {e}").into());
2616+ this.notify_user(format!("SCAN FAILED: {e}").into());
25952617 }
25962618 }
25972619 cx.notify();
@@ -2719,7 +2741,7 @@ impl Player {
27192741 /// nothing.
27202742 fn previewed(&mut self) -> Option<(Vec<(u32, u32)>, Vec<Lane>)> {
27212743 if self.silence_marks.is_empty() {
2722- self.notice = Some(
2744+ self.notify_user(
27232745 format!(
27242746 "no silence under {:.0} dBFS lasting {:.2} s — raise the threshold or forgive less",
27252747 self.silence.threshold_db, self.silence.min_silence
@@ -2771,7 +2793,7 @@ impl Player {
27712793 // moves indexes (a delete, a paste, an undo).
27722794 self.selected = None;
27732795 self.reset_after_reseek();
2774- self.notice = Some(
2796+ self.notify_user(
27752797 format!(
27762798 "{count} SILENCES CUT {reach} — {} shorter, {} takes it back",
27772799 secs_label(saved),
@@ -2780,7 +2802,7 @@ impl Player {
27802802 .into(),
27812803 );
27822804 }
2783- Err(e) => self.notice = Some(e.to_string().into()),
2805+ Err(e) => self.notify_user(e.to_string().into()),
27842806 }
27852807 cx.notify();
27862808 }
@@ -2810,7 +2832,7 @@ impl Player {
28102832 // goes with them.
28112833 self.selected = None;
28122834 self.reset_after_reseek();
2813- self.notice = Some(
2835+ self.notify_user(
28142836 format!(
28152837 "{count} SILENCES AT {rate} {reach} — {} takes it back",
28162838 self.keymap.display(ActionId::Undo)
@@ -2818,7 +2840,7 @@ impl Player {
28182840 .into(),
28192841 );
28202842 }
2821- Err(e) => self.notice = Some(e.to_string().into()),
2843+ Err(e) => self.notify_user(e.to_string().into()),
28222844 }
28232845 cx.notify();
28242846 }
@@ -2926,7 +2948,7 @@ impl Player {
29262948 _ => None,
29272949 };
29282950 if let Some(refusal) = refusal {
2929- self.notice = Some(refusal.into());
2951+ self.notify_user(refusal.into());
29302952 cx.notify();
29312953 return;
29322954 }
@@ -3016,7 +3038,7 @@ impl Player {
30163038 /// band that was just made. Refused rather than silently ignored at the cap.
30173039 fn add_band(&mut self, cx: &mut Context<Self>) {
30183040 if self.eq_params.bands.len() >= EQ_BANDS_MAX {
3019- self.notice = Some(
3041+ self.notify_user(
30203042 format!(
30213043 "EQUALIZER FULL — {EQ_BANDS_MAX} bands is all this card holds; move one instead"
30223044 )
@@ -3035,7 +3057,7 @@ impl Player {
30353057 /// is a card with nothing to edit, and flattening is what "off" means here.
30363058 fn remove_band(&mut self, cx: &mut Context<Self>) {
30373059 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());
30393061 cx.notify();
30403062 return;
30413063 }
@@ -3122,7 +3144,7 @@ impl Player {
31223144 if session.regroup_at(session.now()) {
31233145 self.selected = None;
31243146 } else {
3125- self.notice = Some(
3147+ self.notify_user(
31263148 "NOTHING TO REGROUP — put the playhead where two clips meet, on frames that were cut apart"
31273149 .into(),
31283150 );
@@ -3142,12 +3164,13 @@ impl Player {
31423164 match (&mut self.session, self.selected) {
31433165 (Some(session), Some((lane, idx))) => {
31443166 if !session.ungroup(lane, idx) {
3145- self.notice =
3146- Some("NOTHING DETACHED — that clip is not grouped with another".into());
3167+ self.notify_user(
3168+ "NOTHING DETACHED — that clip is not grouped with another".into(),
3169+ );
31473170 }
31483171 }
31493172 (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())
31513174 }
31523175 (None, _) => {}
31533176 }
@@ -3171,17 +3194,17 @@ impl Player {
31713194 match (&mut self.session, self.selected, partner) {
31723195 (Some(session), Some((lane, idx)), Some((other, o_idx))) => {
31733196 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());
31753198 }
31763199 }
31773200 (Some(_), Some(_), None) => {
3178- self.notice = Some(
3201+ self.notify_user(
31793202 "NOTHING TO GROUP WITH — no clip on another track covers exactly these frames"
31803203 .into(),
31813204 )
31823205 }
31833206 (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())
31853208 }
31863209 (None, ..) => {}
31873210 }
@@ -3211,7 +3234,7 @@ impl Player {
32113234 _ => false,
32123235 };
32133236 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());
32153238 }
32163239 if deleted {
32173240 self.reset_after_reseek();
@@ -3231,11 +3254,11 @@ impl Player {
32313254 if session.lift_clip(lane, idx) {
32323255 self.reset_after_reseek();
32333256 } 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());
32353258 }
32363259 }
32373260 (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())
32393262 }
32403263 (None, _) => {}
32413264 }
@@ -3516,7 +3539,7 @@ impl Player {
35163539 // Everything else that could refuse (a clip that is not there)
35173540 // cannot be dragged.
35183541 false if from.kind != to.kind => {
3519- self.notice = Some(
3542+ self.notify_user(
35203543 format!(
35213544 "NOT ON {} — that is a {kind} clip; drop it on a {lanes} lane",
35223545 to.label()
@@ -3528,7 +3551,7 @@ impl Player {
35283551 // says nothing.
35293552 false if from == to && start == was => {}
35303553 false => {
3531- self.notice = Some(
3554+ self.notify_user(
35323555 format!(
35333556 "NOT MOVED — another clip already covers those frames on {}",
35343557 to.label()
@@ -3909,7 +3932,7 @@ impl Player {
39093932 // refused here -- where a file goes when nobody says is the engine's
39103933 // choice, in `place_stream_at`, not one made twice here.
39113934 if let Some(why) = onto.and_then(|lane| lane_refuses(path, lane)) {
3912- self.notice = Some(why.into());
3935+ self.notify_user(why.into());
39133936 cx.notify();
39143937 return;
39153938 }
@@ -3936,9 +3959,9 @@ impl Player {
39363959 }
39373960 // The engine's own words: a stream that cannot join this timeline
39383961 // 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()),
39403963 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())
39423965 }
39433966 }
39443967 cx.notify();
@@ -3999,7 +4022,7 @@ impl Player {
39994022 Some(Err(e)) => format!("NOT REMOVED — {e}"),
40004023 None => "NO TIMELINE — open a file first".to_string(),
40014024 };
4002- self.notice = Some(text.into());
4025+ self.notify_user(text.into());
40034026 cx.notify();
40044027 }
40054028
@@ -4279,7 +4302,7 @@ impl Player {
42794302 Landed::Media(opened, place) => {
42804303 let text = self.install_media(path, opened, place);
42814304 eprintln!("{text}");
4282- self.notice = Some(text.into());
4305+ self.notify_user(text.into());
42834306 cx.notify();
42844307 }
42854308 Landed::Read(..) => unreachable!("matched above"),
@@ -4347,7 +4370,7 @@ impl Player {
43474370 None => self.open_media(path, false, subs),
43484371 };
43494372 eprintln!("{text}");
4350- self.notice = Some(text.into());
4373+ self.notify_user(text.into());
43514374 cx.notify();
43524375 }
43534376
@@ -4431,7 +4454,7 @@ impl Player {
44314454 Ok(None) => {}
44324455 Err(text) => {
44334456 eprintln!("{text}");
4434- this.notice = Some(text.into());
4457+ this.notify_user(text.into());
44354458 cx.notify();
44364459 }
44374460 })
@@ -4456,7 +4479,7 @@ impl Player {
44564479 if let Some(why) = self.enable(ActionId::AddSubtitleTrack, None).why() {
44574480 let text = format!("NO SUBTITLES ADDED — {why}");
44584481 eprintln!("{text}");
4459- self.notice = Some(text.into());
4482+ self.notify_user(text.into());
44604483 cx.notify();
44614484 return;
44624485 }
@@ -4471,7 +4494,7 @@ impl Player {
44714494 Ok(None) => {}
44724495 Err(text) => {
44734496 eprintln!("{text}");
4474- this.notice = Some(text.into());
4497+ this.notify_user(text.into());
44754498 cx.notify();
44764499 }
44774500 })
@@ -4495,7 +4518,7 @@ impl Player {
44954518 self.landed_subtitles(path, None, cx);
44964519 return;
44974520 }
4498- self.notice = Some(format!("READING {} for subtitles…", file_name(path)).into());
4521+ self.notify_user(format!("READING {} for subtitles…", file_name(path)).into());
44994522 let parsed = cx.background_executor().spawn({
45004523 let path = path.to_path_buf();
45014524 async move { engine::PlaybackSession::parse_subtitles(&path) }
@@ -4553,7 +4576,7 @@ impl Player {
45534576 None => "NO SUBTITLES ADDED — open a file for them to run against first".to_string(),
45544577 };
45554578 eprintln!("{text}");
4556- self.notice = Some(text.into());
4579+ self.notify_user(text.into());
45574580 cx.notify();
45584581 }
45594582
@@ -4576,7 +4599,7 @@ impl Player {
45764599 if let Some(why) = self.enable(ActionId::RemoveSubtitleTrack, None).why() {
45774600 let text = format!("NO SUBTITLES REMOVED — {why}");
45784601 eprintln!("{text}");
4579- self.notice = Some(text.into());
4602+ self.notify_user(text.into());
45804603 cx.notify();
45814604 return;
45824605 }
@@ -4609,7 +4632,7 @@ impl Player {
46094632 None => "NO SUBTITLES REMOVED — open a file first".to_string(),
46104633 };
46114634 eprintln!("{text}");
4612- self.notice = Some(text.into());
4635+ self.notify_user(text.into());
46134636 cx.notify();
46144637 }
46154638
@@ -4672,7 +4695,7 @@ impl Player {
46724695 Err(e) => format!("OPEN FAILED: {e}"),
46734696 };
46744697 eprintln!("{text}");
4675- self.notice = Some(text.into());
4698+ self.notify_user(text.into());
46764699 cx.notify();
46774700 }
46784701
@@ -4689,7 +4712,7 @@ impl Player {
46894712 None => "NOTHING TO SAVE — open a file first".to_string(),
46904713 };
46914714 eprintln!("{text}");
4692- self.notice = Some(text.into());
4715+ self.notify_user(text.into());
46934716 cx.notify();
46944717 }
46954718
@@ -4704,7 +4727,7 @@ impl Player {
47044727 match &mut self.session {
47054728 Some(session) => {
47064729 let lane = session.add_lane(kind);
4707- self.notice = Some(
4730+ self.notify_user(
47084731 format!(
47094732 "{} ADDED — drag a clip onto it, {} takes it back",
47104733 lane.label(),
@@ -4713,7 +4736,7 @@ impl Player {
47134736 .into(),
47144737 );
47154738 }
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()),
47174740 }
47184741 cx.notify();
47194742 }
@@ -4752,7 +4775,7 @@ impl Player {
47524775 Some(Err(e)) => format!("NO TRACK REMOVED — {e}"),
47534776 None => "NO TRACK REMOVED — open a file first".to_string(),
47544777 };
4755- self.notice = Some(text.into());
4778+ self.notify_user(text.into());
47564779 cx.notify();
47574780 }
47584781
@@ -4770,7 +4793,7 @@ impl Player {
47704793 match last {
47714794 Some(lane) => self.remove_lane(lane, cx),
47724795 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());
47744797 cx.notify();
47754798 }
47764799 }
@@ -4804,7 +4827,7 @@ impl Player {
48044827 if !chord.bindable() {
48054828 let text = format!("THAT KEY CANNOT BE BOUND — {}", chord.pretty());
48064829 eprintln!("{text}");
4807- self.notice = Some(text.into());
4830+ self.notify_user(text.into());
48084831 return;
48094832 }
48104833 let text = match self.keymap.rebind_action(action, chord.clone()) {
@@ -4821,7 +4844,7 @@ impl Player {
48214844 Err(holder) => format!("ALREADY BOUND — {} is {}", chord.pretty(), holder.label()),
48224845 };
48234846 eprintln!("{text}");
4824- self.notice = Some(text.into());
4847+ self.notify_user(text.into());
48254848 }
48264849
48274850 /// Seeks to where the pointer sits along the ruler. `commit` is the press
@@ -4889,7 +4912,7 @@ impl Player {
48894912 if nothing_to_play(self.session.as_ref()) {
48904913 match self.session.as_mut().filter(|s| s.is_playing()) {
48914914 Some(session) => session.pause(),
4892- None => self.notice = Some(NOTHING_TO_PLAY.into()),
4915+ None => self.notify_user(NOTHING_TO_PLAY.into()),
48934916 }
48944917 cx.notify();
48954918 return;
@@ -4932,7 +4955,7 @@ impl Player {
49324955 // Nothing to write out, and a refusal rather than a card about it: the
49334956 // window is empty and the export path is not even chosen yet.
49344957 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());
49364959 cx.notify();
49374960 return;
49384961 }
@@ -4957,7 +4980,7 @@ impl Player {
49574980 .as_ref()
49584981 .and_then(|session| format_refusal(session, format))
49594982 {
4960- self.notice = Some(format!("NOT {} — {why}", format_label(format)).into());
4983+ self.notify_user(format!("NOT {} — {why}", format_label(format)).into());
49614984 return;
49624985 }
49634986 self.format = format;
@@ -4977,7 +5000,7 @@ impl Player {
49775000 /// looking broken.
49785001 fn cycle_quality(&mut self) {
49795002 if let Some(why) = bitrate_refusal(self.format) {
4980- self.notice = Some(why.into());
5003+ self.notify_user(why.into());
49815004 return;
49825005 }
49835006 let at = Quality::ALL
@@ -4994,7 +5017,7 @@ impl Player {
49945017 /// card looking broken.
49955018 fn cycle_audio_kbps(&mut self) {
49965019 if let Some(why) = self.audio_rate_refusal() {
4997- self.notice = Some(why.into());
5020+ self.notify_user(why.into());
49985021 return;
49995022 }
50005023 self.audio_kbps = next_audio_kbps(self.audio_kbps);
@@ -5055,7 +5078,7 @@ impl Player {
50555078 Ok(None) => {}
50565079 Err(text) => {
50575080 eprintln!("{text}");
5058- this.notice = Some(text.into());
5081+ this.notify_user(text.into());
50595082 }
50605083 }
50615084 cx.notify();
@@ -5123,7 +5146,7 @@ impl Player {
51235146 // calls for the *estimate* and which nothing else needs a subtitle for.
51245147 settings.subtitles = self.export_subs();
51255148 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());
51275150 cx.notify();
51285151 return;
51295152 };
@@ -5133,7 +5156,7 @@ impl Player {
51335156 // that is not this button cannot get past it either. Two fences on
51345157 // purpose: this one is the one with a keystroke to blame.
51355158 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());
51375160 cx.notify();
51385161 return;
51395162 }
@@ -5142,7 +5165,7 @@ impl Player {
51425165 // edit away -- so the button asks again rather than starting a worker
51435166 // that will only settle with the same refusal minutes later.
51445167 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());
51465169 cx.notify();
51475170 return;
51485171 }
@@ -5202,7 +5225,7 @@ impl Player {
52025225 Err(e) => format!("EXPORT FAILED: {e}"),
52035226 };
52045227 eprintln!("{text}");
5205- self.notice = Some(text.into());
5228+ self.notify_user(text.into());
52065229 }
52075230 }
52085231
@@ -5293,11 +5316,12 @@ impl Render for Player {
52935316 {
52945317 return;
52955318 }
5296- // Any key retires the last message, whatever it was -- and owes
5319+ // Any key answers the message on the bar and brings the next of
5320+ // them up, whatever it was -- and owes
52975321 // the repaint itself: a notice no longer keeps the render loop
52985322 // alive, and the arms below that do notify are not all of them
52995323 // (an unbound key, or the copy chord, changes nothing else).
5300- if this.notice.take().is_some() {
5324+ if this.dismiss_notice() {
53015325 cx.notify();
53025326 }
53035327 // 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 {
61166140 )
61176141 }
61186142
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+
61196165 /// The tail an open/load notice grows when the file has sound the engine cannot
61206166 /// decode: it plays perfectly, in silence, and that is the one thing the window
61216167 /// would otherwise never say (the engine's own word for it, verbatim).
@@ -9510,7 +9556,8 @@ mod tests {
95109556 marked, menu_at, menu_items, menu_rows_h, next_audio_kbps, next_container, normalise, nothing_to_play, panel_h, project_path,
95119557 retarget, row_enable, row_items, scrub_due, secs_label, show_label, silence_rate, size_label, snap_cue, snap_marks, snapped,
95129558 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,
95149561 whole_take, window_title,
95159562 };
95169563 use super::{
@@ -9566,6 +9613,7 @@ mod tests {
95669613 fn ui_source() -> String {
95679614 [
95689615 include_str!("main.rs").split("#[cfg(test)]").next().unwrap(),
9616+ include_str!("ui/theme.rs"),
95699617 include_str!("ui/toolbar.rs"),
95709618 include_str!("ui/inspector.rs"),
95719619 include_str!("ui/timeline.rs"),
@@ -14279,6 +14327,46 @@ mod tests {
1427914327 assert!(stray.is_empty(), "colour written outside the theme: {stray:?}");
1428014328 }
1428114329
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+
1428214370 /// The cards are sections of the inspector, not sheets over the timeline:
1428314371 /// adjusting a clip must never hide the clip. Structural, because that is
1428414372 /// where the rule lives -- a card rendered from the root again would be an
@@ -15382,7 +15470,7 @@ fn main() {
1538215470 // there was anything to pick.
1538315471 format: Format::default(),
1538415472 rebinding: None,
15385- notice: notice.clone().map(SharedString::from),
15473+ notices: notice.clone().map(SharedString::from).into_iter().collect(),
1538615474 exported: None,
1538715475 // The whole of argv, waiting for the first repaint to start
1538815476 // 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 {
473473 .px(px(6.))
474474 .text_size(px(11.))
475475 .text_color(rgb(FG_SECONDARY))
476- .child(match (&self.mbps_edit, &self.notice) {
476+ .child(match (&self.mbps_edit, self.notices.front()) {
477477 // A field being typed into says so here as
478478 // well as in its row: this line is outside
479479 // the scrolling list and on screen at every
@@ -775,7 +775,7 @@ impl Player {
775775 .px(px(6.))
776776 .text_size(px(11.))
777777 .text_color(rgb(FG_SECONDARY))
778- .child(self.notice.clone().unwrap_or_else(|| {
778+ .child(self.notices.front().cloned().unwrap_or_else(|| {
779779 "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()
780780 })),
781781 )
crates/app/src/ui/overlays.rsmodified+23 -7
@@ -113,17 +113,27 @@ impl Player {
113113 /// now on disk, so the same click that retires it shows that file in the
114114 /// desktop's file manager.
115115 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()?;
117117 // The path travels with the text it was written for: a later notice
118118 // holds the bar and the click is a plain dismissal again.
119119 let exported = self
120120 .exported
121121 .clone()
122122 .filter(|_| notice.starts_with(EXPORT_DONE));
123- let hint = match exported {
124- Some(_) => "click — open file location",
125- None => "click or press any key to dismiss",
123+ // How many are waiting behind this one, said out loud: a queue nobody is
124+ // told about is a queue whose second message reads as the first one
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"),
126132 };
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);
127137 Some(
128138 div()
129139 .id("notice")
@@ -142,6 +152,11 @@ impl Player {
142152 .px(px(12.))
143153 .py(px(6.))
144154 .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))
145160 .cursor_pointer()
146161 .hover(|s| s.bg(rgb(BG_HOVER)))
147162 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
@@ -152,7 +167,7 @@ impl Player {
152167 .spawn(async move { show_in_file_manager(&path) })
153168 .detach();
154169 }
155- this.notice = None;
170+ this.dismiss_notice();
156171 cx.notify();
157172 }))
158173 .child(div().flex_1().min_w(px(0.)).child(notice))
@@ -371,8 +386,9 @@ impl Player {
371386 .text_size(px(11.))
372387 .text_color(rgb(FG_SECONDARY))
373388 .child(
374- self.notice
375- .clone()
389+ self.notices
390+ .front()
391+ .cloned()
376392 .unwrap_or_else(|| {
377393 "click an action to do it · click its key to change it"
378394 .into()
crates/app/src/ui/theme.rsmodified+22 -0
@@ -84,6 +84,28 @@ pub const STATUS_ERROR: u32 = 0xef4444;
8484 pub const STATUS_WARNING: u32 = 0xf59e0b;
8585 pub const STATUS_SUCCESS: u32 = 0x34d399;
8686 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+
87109 /// The mirror of [`BG_SELECTED`]: a drop the lane will not take, tinting the
88110 /// shadow the drag draws so a refusal is seen before the release.
89111 pub const DROP_REFUSE: u32 = 0x8f2740;