refactor: retain refresh traversal and unpublished window documents across polls

This commit is contained in:
2026-10-23 01:20:00 +08:00
parent 175421ece3
commit 3a636a8a79
4 changed files with 256 additions and 101 deletions
+23
View File
@@ -228,6 +228,7 @@ struct Session {
next_window: u64,
next_mount: u64,
retired_commands: Vec<crate::window::Command>,
refresh_yields: usize,
}
impl std::ops::Deref for Session {
@@ -1153,6 +1154,7 @@ impl NativeCallable for Function {
("arranged", session.layout.arranged as i64),
("layoutPasses", session.layout.settle_passes as i64),
("layoutSlices", session.layout.slices as i64),
("refreshYields", session.refresh_yields as i64),
] {
cx.set_attr(stats, name, Value::Number(value.into()))?;
}
@@ -2590,6 +2592,26 @@ impl UiBridge {
self.accept_layout_progress(vm, context, progress)
}
pub fn note_refresh_yield(&self) -> Result<()> {
let mut state = self
.session
.lock()
.map_err(|_| anyhow::anyhow!("UI session poisoned"))?;
state.refresh_yields = state.refresh_yields.saturating_add(1);
Ok(())
}
// Abort is currently a fault-domain cleanup operation, not a live rollback
// of Mount preparation. The caller preserves the last published picture.
pub fn abort_layout_frame(&self, vm: &mut Vm, pending: PendingLayout) -> Result<()> {
let PendingLayout { work, context } = pending;
let cancelled = work.cancel(vm);
let released = context.hooks.map(|hooks| vm.release(hooks)).transpose();
cancelled?;
released?;
Ok(())
}
pub fn resume_layout_frame(
&self,
vm: &mut Vm,
@@ -2760,6 +2782,7 @@ pub fn install(vm: &mut Vm, roots: &mut Vec<ObjectRef>) -> Result<UiBridge> {
next_window: crate::window::MAIN_WINDOW,
next_mount: 0,
retired_commands: Vec::new(),
refresh_yields: 0,
}));
let mut public_functions = Vec::new();
let mut factories = Vec::new();