forge
Explore
Log in

Don't you dare go Hollow

The notice plate reads the newest message, not the stalest

Browse files at this commit

d3bace229af7c256351678aab0bfbc09fa542df4Ahmet Kaan GümüşParent: 7f487c1
  • fix
    • the notice plate reads the newest message, not the stalest
Show full message
fix(ui): the notice plate reads the newest message, not the stalest

notice_plate showed notices.front() while the ledger's "last action"
already read notices.back() -- and nothing but a keystroke ever calls
dismiss_notice(), so a mouse-driven refusal queued behind an earlier,
undismissed notice (a ctrl+s "SAVED ...") never reached the plate at
all. The plate now reads back(), matching the ledger, so the newest
notice is always the one shown; its max width also grows from 360 to
480px so a refusal-plus-remedy sentence gets two or three lines
instead of being left to the ledger's single truncated line.
crates/app/src/notices.rsmodified+35 -0
@@ -58,3 +58,38 @@ pub(crate) fn audio_notice(session: &PlaybackSession) -> Option<String> {
58 .audio_disabled_reason()58 .audio_disabled_reason()
59 .map(|reason| format!(" — NO AUDIO: {reason}"))59 .map(|reason| format!(" — NO AUDIO: {reason}"))
60 }60 }
61+
62+#[cfg(test)]
63+mod tests {
64+ use super::*;
65+
66+ /// The class this guards: a notice queued behind an earlier, undismissed
67+ /// one is never *lost* -- `push_notice` still appends it to the back --
68+ /// but a reader of `front()` alone (what `stance::notice_plate` read
69+ /// before this fix) would never see it, because nothing but a keystroke
70+ /// ever calls `dismiss_notice`, and most of what fills this queue (a
71+ /// click on a gap, a menu row, a drag) is not one. `back()` is the read
72+ /// that survives that: it always names the newest message, which is why
73+ /// the plate and the ledger's "last action" both read it now.
74+ ///
75+ /// This is a value-level check on the queue only -- this binary has no
76+ /// `TestAppContext`, so it cannot measure what actually painted, and this
77+ /// test does not claim to.
78+ #[test]
79+ fn a_notice_queued_behind_an_unread_one_is_still_reachable_at_the_back() {
80+ let mut notices = std::collections::VecDeque::new();
81+ push_notice(&mut notices, "SAVED test_h264.edith".into());
82+ let refusal = "the V1 clip at frame 0 is one take with the A1 clip at frame 0: \
83+ closing this gap alone would pull the take out of sync — close A1's \
84+ gap there too, or detach them first";
85+ push_notice(&mut notices, refusal.into());
86+ // Nobody dismissed the SAVED notice (no keystroke happened) -- it is
87+ // still sitting at the front, exactly the scenario that froze the
88+ // plate on stale text.
89+ assert_eq!(notices.front().unwrap().as_ref(), "SAVED test_h264.edith");
90+ // The refusal, remedy clause and all, is reachable at the back --
91+ // whole, not truncated, because `push_notice` never touches a
92+ // message's text.
93+ assert_eq!(notices.back().unwrap().as_ref(), refusal);
94+ }
95+}
crates/app/src/ui/stance.rsmodified+20 -6
@@ -562,9 +562,18 @@ pub(crate) fn notice_bottom_offset(bench_h: f32) -> f32 {
562 /// A notice plate (DESIGN §8): one at a time, rising above the *bench*, its562 /// A notice plate (DESIGN §8): one at a time, rising above the *bench*, its
563 /// severity a 3px left spine rather than a colour flood. Fed by the same563 /// severity a 3px left spine rather than a colour flood. Fed by the same
564 /// [`Player::notify_user`]/`notices` queue the legacy bar reads564 /// [`Player::notify_user`]/`notices` queue the legacy bar reads
565-/// ([`Player::notice_bar`]) -- no second notice channel. Dismissal is565+/// ([`Player::notice_bar`]) -- no second notice channel.
566-/// already wired: [`render`]'s `on_key_down` calls `dismiss_notice()` on566+///
567-/// every stroke, the same door the legacy handler uses.567+/// Reads the *back* of the queue, not the front: dismissal only ever fires
568+/// on a keystroke ([`render`]'s `on_key_down` calling `dismiss_notice()`),
569+/// and most of what fills this queue -- a click on a gap, a menu row, a
570+/// drag -- is not one. A `front()` plate left showing a `ctrl+s` "SAVED"
571+/// notice sat frozen through an unrelated mouse-driven refusal that queued
572+/// in behind it: the ledger strip's own "last action" already reads
573+/// `back()` for exactly this reason, and the plate disagreeing with it is
574+/// what made the refusal look like it never reached the notice surface at
575+/// all. `back()` keeps the two in step and guarantees the newest, most
576+/// actionable message is always the one on screen.
568 ///577 ///
569 /// Anchored off `bench_h` rather than a fixed offset off the ledger: at the578 /// Anchored off `bench_h` rather than a fixed offset off the ledger: at the
570 /// bench's floor a fixed `LEDGER_H + 6.` bottom offset put the plate right579 /// bench's floor a fixed `LEDGER_H + 6.` bottom offset put the plate right
@@ -585,9 +594,14 @@ fn notice_plate(message: SharedString, bench_h: f32) -> impl IntoElement {
585 .absolute()594 .absolute()
586 .bottom(px(notice_bottom_offset(bench_h)))595 .bottom(px(notice_bottom_offset(bench_h)))
587 .left(px(12.))596 .left(px(12.))
588- .max_w(px(360.))597+ // Wide enough to hold a refusal-plus-remedy sentence in two or three
598+ // lines rather than one line cut mid-word: the ledger strip below is
599+ // the one place that must stay a single truncated line (it also
600+ // carries the project identity, export progress and the timecode on
601+ // the same row), so this plate is the surface with room, and it
602+ // takes it.
603+ .max_w(px(480.))
589 .flex()604 .flex()
590- .items_center()
591 .px(px(10.))605 .px(px(10.))
592 .py(px(6.))606 .py(px(6.))
593 .rounded(px(2.))607 .rounded(px(2.))
@@ -922,7 +936,7 @@ pub(crate) fn render(
922 .child(divider(Split::Bench, cx))936 .child(divider(Split::Bench, cx))
923 .child(bench(player, bench_h, cx))937 .child(bench(player, bench_h, cx))
924 .child(ledger(player, position))938 .child(ledger(player, position))
925- .when_some(player.notices.front().cloned(), |el, n| {939+ .when_some(player.notices.back().cloned(), |el, n| {
926 el.child(notice_plate(n, bench_h))940 el.child(notice_plate(n, bench_h))
927 })941 })
928 .when(player.keys_open, |el| el.child(keys_overlay(player)))942 .when(player.keys_open, |el| el.child(keys_overlay(player)))