Preserve queued notice order for script messages

This commit is contained in:
Dylan M. Taylor
2026-11-20 14:33:51 -05:00
parent e81613035b
commit 4dbf6c092e
2 changed files with 7 additions and 3 deletions
+2
View File
@@ -240,6 +240,8 @@ impl PdfCraftApp {
pub(crate) fn script_tick(&mut self, ctx: &egui::Context) {
// A message queued before the window had a context is posted on the first pass.
if self.script_shown.is_none() && !self.script_messages.is_empty() {
// Requests from the same script may already have queued notices; post those first.
crate::notices::post_queued(self, ctx);
self.next_script_message(ctx);
}
// Nothing acts on the document under a dialog or prompt (`modal_open`): page actions and
+5 -3
View File
@@ -151,10 +151,11 @@ fn texts(h: &Harness<'static, PdfCraftApp>) -> Vec<String> {
/// The user's close action on every card, then the passes that act on it.
fn dismiss_all(h: &mut Harness<'static, PdfCraftApp>) {
for card in toast::cards(&h.ctx, &WindowKey::main()) {
toast::dismiss(&h.ctx, card.id);
// Programmatic removal emits no close event; use the user's dismiss control.
for button in h.query_all_by(|node| !node.is_hidden() && node.label().as_deref() == Some("Dismiss")) {
button.click();
}
h.run_steps(2);
h.run_steps(3);
}
/// One run's messages are all shown, in order (#4294): the first is a card with its title and tone
@@ -196,6 +197,7 @@ fn every_message_a_script_shows_takes_the_toast_in_turn() {
// have been shown.
let many: Vec<_> = (0..105).map(|i| pdfcraft_engine::js::Message::plain(format!("Message {i}"))).collect();
h.state_mut().show_script_messages(many);
h.run_steps(2);
assert_eq!(texts(&h), ["Message 0"]);
for i in 1..100 {
dismiss_all(&mut h);