Keep native control renders responsive (#3306)

* Keep native control renders responsive

* Refresh replies for immediately completed render jobs

* #3289: Bind waiting replies to their native render
This commit is contained in:
FredApps authored and GitHub committed 2026-11-08 16:43:06 +01:00
1 parent 07be19d402
commit 86c08aa0ee
20 files changed
+950 -29

No files matched your search

+6
View File
@@ -7,6 +7,9 @@ impl Session {
/// Run a command by id.
pub fn execute(&mut self, id: &str, params: Value) -> Result<Value> {
if self.script_ui.render_host.is_some() && !crate::scriptui::allowed_during_render(id) {
return Err(EngineError::Other(crate::scriptui::RENDER_WAIT_MESSAGE.into()));
}
let spec = commands::find(id).ok_or_else(|| EngineError::UnknownCommand(id.to_string()))?;
if let Err(why) = (spec.enabled)(self) {
// Explicit targets (agents, scripts) don't need a UI selection.
@@ -57,6 +60,9 @@ impl Session {
/// Whether `id` names a known command whose `enabled` predicate returns `Ok` for this session;
/// an unknown id or a predicate error reads as disabled.
pub fn is_enabled(&self, id: &str) -> bool {
if self.script_ui.render_host.is_some() && !crate::scriptui::allowed_during_render(id) {
return false;
}
commands::find(id).is_some_and(|c| (c.enabled)(self).is_ok())
}
+12
View File
@@ -30,6 +30,9 @@ impl Session {
/// undo step under `label`, unless it merges with the current merge key (then the redo branch
/// is dropped). An `Err` from `f` propagates with the session unchanged.
fn edit_inner<T>(&mut self, label: &str, merge: Option<&str>, f: impl FnOnce(&mut Project, &mut EditorState) -> Result<T>) -> Result<T> {
if self.script_ui.render_host.is_some() {
return Err(EngineError::Other(crate::scriptui::RENDER_WAIT_MESSAGE.into()));
}
let before = self.project.clone();
let mut p = (*self.project).clone();
let mut st = self.state.clone();
@@ -105,6 +108,9 @@ impl Session {
/// modified) but is no undo step, and it changes no pixels: the comp's cached frames stay
/// valid ([`effectcraft_project::Comp::same_pixels`]).
pub fn set_resolution(&mut self, comp: ItemId, r: effectcraft_project::Resolution) -> Result<()> {
if self.script_ui.render_host.is_some() {
return Err(EngineError::Other(crate::scriptui::RENDER_WAIT_MESSAGE.into()));
}
if self.project.comp(comp).ok_or(EngineError::NoComp)?.resolution == r {
return Ok(());
}
@@ -134,6 +140,9 @@ impl Session {
/// on-canvas editor gets a new IME epoch only when its own document changed) and the session is
/// bumped. Returns `false`, changing nothing, when there is nothing to undo.
pub fn undo(&mut self) -> bool {
if self.script_ui.render_host.is_some() {
return false;
}
let Some((label, p)) = self.history.undo.pop() else { return false };
let edited = commands::text_edit::active_editor_snapshot(self);
let probe = commands::kept_crypto_probe(self);
@@ -152,6 +161,9 @@ impl Session {
/// text document starts a new IME epoch) and the session is bumped. Returns `false`, changing
/// nothing, when there is nothing to redo.
pub fn redo(&mut self) -> bool {
if self.script_ui.render_host.is_some() {
return false;
}
let Some((label, p)) = self.history.redo.pop() else { return false };
let edited = commands::text_edit::active_editor_snapshot(self);
let probe = commands::kept_crypto_probe(self);