From 73d089cabd8e454e32377954d52f4cbf9489231c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 12:00:58 -0800 Subject: [PATCH] Queue browser uploads while plugin workers hold documents --- crates/ui-egui/src/app/files.rs | 3 +++ crates/ui-egui/src/tests/plugin_runs.rs | 27 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/crates/ui-egui/src/app/files.rs b/crates/ui-egui/src/app/files.rs index 7019cc3abd..30069d71e2 100644 --- a/crates/ui-egui/src/app/files.rs +++ b/crates/ui-egui/src/app/files.rs @@ -30,6 +30,9 @@ impl VectorcraftApp { } pub(crate) fn drain_inbox(&mut self) { + if self.session.plugin_calls_open() { + return; + } fn take(q: Option<&Inbox>) -> Vec<(String, Vec)> { q.map(|q| std::mem::take(&mut *q.lock().unwrap_or_else(|e| e.into_inner()))).unwrap_or_default() } diff --git a/crates/ui-egui/src/tests/plugin_runs.rs b/crates/ui-egui/src/tests/plugin_runs.rs index bbe1d60c7d..bb8d669b30 100644 --- a/crates/ui-egui/src/tests/plugin_runs.rs +++ b/crates/ui-egui/src/tests/plugin_runs.rs @@ -1095,6 +1095,33 @@ fn on_the_web_the_progress_window_shows_the_run_that_holds_the_documents_first() app.run("plugin.cancelRuns", json!({})).unwrap(); } +#[test] +fn browser_file_inboxes_wait_for_a_run_that_holds_the_documents() { + let (mut app, _fake) = web_app(); + let id = "test.ui.web.held.file.inbox"; + install_caller(&mut app, id, TRIANGLE); + let bytes = vectorcraft_format::save(&app.session.doc().unwrap().doc, true); + let incoming = crate::services::Inbox::default(); + let page = crate::services::Inbox::default(); + app.services.inbox = Some(incoming.clone()); + app.services.page_inbox = Some(page.clone()); + app.run("plugin.dialog", json!({"id": id})).unwrap(); + let before = app.session.documents().len(); + let active = app.session.active().unwrap().uid; + incoming.lock().unwrap().push(("Incoming.vectorcraft".into(), bytes.clone())); + page.lock().unwrap().push(("Page.vectorcraft".into(), bytes)); + app.drain_inbox(); + assert_eq!(app.session.documents().len(), before); + assert_eq!(app.session.active().unwrap().uid, active); + assert_eq!(incoming.lock().unwrap().len(), 1); + assert_eq!(page.lock().unwrap().len(), 1); + app.run("plugin.cancelRuns", json!({})).unwrap(); + app.drain_inbox(); + assert_eq!(app.session.documents().len(), before + 2); + assert!(incoming.lock().unwrap().is_empty()); + assert!(page.lock().unwrap().is_empty()); +} + /// While a script runs, a worker run still gets its request and its time budget still ends it, and /// no other run starts in a worker. #[test]