2 Commits

Author SHA1 Message Date
codex-bot 514eeb8648 test: cover shared paint dependencies across windows
Verify Tessera GUI / verify (push) Successful in 2m22s
2026-10-24 01:55:27 +08:00
codex-bot ae3a2d6163 fix: exclude shared host desktop bookkeeping from visual dependencies 2026-10-24 01:55:27 +08:00
4 changed files with 89 additions and 3 deletions
+2
View File
@@ -244,3 +244,5 @@ Foreground REPL/events now retain a BeforeInput request while an existing idle l
Source layout/paint now validate name-level read observations from Aster: each globals/builtins lookup records its text key and observed presence/value, while dictionary kind checks remain separate. Updating the REPL result `_` or another unread global no longer invalidates these frames solely because the whole globals dictionary version changed. Reading `_` still observes its value; adding a previously missing global correctly invalidates a builtin fallback. Ordinary native dictionary iteration/content reads retain whole-object version dependencies. Measurement cache hits replay their recorded observations into the outer solve; they do not drop dependencies merely because source execution was skipped. Cache observations contain borrowed handles (including object-valued names), add no GC roots, and never write comparison snapshots back into language objects. Invalid-name diagnostics report only identity/key, not captured values. General Block binding and other legacy readers keep their existing conservative object dependencies. See examples/global-dependencies.endor.
Source layout/paint and measurement caches exclude every presentation's private desktop identity, including the primary desktop captured by shared native visual methods. Per-window bookkeeping must not invalidate another window's source output. This exclusion does not cover managed Window objects, viewport input records, type definitions or business objects; their observed changes remain dependencies.
+51
View File
@@ -2963,6 +2963,57 @@ page.render(block)
.unwrap()
}
#[test]
fn shared_intrinsic_desktop_does_not_repaint_other_windows_on_repl_input() {
let (mut session, _) = ReplSession::load(
r##"
class Painted: RectBlock {
tint: String
function paint(self: Painted, mount: Mount, geometry: Bounds): DisplayList {
drawing = RectBlock.paint(self,mount,geometry)
drawing.commands.at(0).color = self.tint
return drawing
}
}
item = Painted(80,20,0,"#DDEEFF","#ED6A5A")
page = Page()
page.render(item)
window2 = Window()
page2 = Page()
page2.render(item)
page2.moveToWindow(window2)
"##,
"app.main",
901,
1,
)
.unwrap();
assert!(
session
.execute("42", "app.main")
.unwrap()
.document
.is_none()
);
let changed = session
.execute("item.tint = \"#3868D9\"", "app.main")
.unwrap()
.document
.unwrap();
assert!(changed.frame.commands.iter().any(|command| matches!(
command, RenderCommand::RoundedRect { color, .. } if color == "#3868D9"
)));
assert!(
changed.windows[&2]
.frame
.commands
.iter()
.any(|command| matches!(
command, RenderCommand::RoundedRect { color, .. } if color == "#3868D9"
))
);
}
#[test]
fn source_measure_cache_reuses_independent_results_and_invalidates_model_changes() {
let (mut session, initial) = ReplSession::load_with_viewport(
+7
View File
@@ -48,6 +48,13 @@ pub struct Cache {
pub misses: usize,
}
impl Cache {
pub(crate) fn exclude_host_desktops(&mut self, desktops: &HashSet<ObjectRef>) {
for entry in self.entries.values_mut() {
entry
.reads
.retain(|read| !desktops.contains(&read.object()));
}
}
pub fn invalidate(&mut self, owners: &HashSet<ObjectRef>) {
self.entries
.retain(|_, entry| !owners.contains(&entry.owner));
+29 -3
View File
@@ -236,6 +236,15 @@ struct Session {
exiting: bool,
}
impl Session {
fn host_desktops(&self) -> std::collections::HashSet<ObjectRef> {
self.presentations
.values()
.map(|view| view.desktop)
.collect()
}
}
impl std::ops::Deref for Session {
type Target = crate::presentation::Presentation;
fn deref(&self) -> &Self::Target {
@@ -2612,11 +2621,18 @@ impl UiBridge {
progress: crate::source_paint::Progress,
) -> Result<crate::source_paint::Progress> {
if let crate::source_paint::Progress::Complete(draft) = &progress {
let (reads, names) = crate::presentation::split_reads(draft.reads.clone());
let mut state = self
.session
.lock()
.map_err(|_| anyhow::anyhow!("UI session poisoned"))?;
let desktops = state.host_desktops();
let reads = draft
.reads
.iter()
.filter(|read| !desktops.contains(&read.object()))
.cloned()
.collect();
let (reads, names) = crate::presentation::split_reads(reads);
state.paint_reads = reads;
state.paint_names = names;
state.paint_slices = draft.slices;
@@ -2893,8 +2909,8 @@ impl UiBridge {
let crate::source_layout::Draft {
mut frame,
runtime: mut layout,
cache,
reads,
mut cache,
mut reads,
} = draft;
let result: Result<crate::document::Frame> = (|| {
self.select_window(window)?;
@@ -2910,6 +2926,16 @@ impl UiBridge {
frame.tabs = tabs;
frame.window = window;
// Capture versions before lifecycle hooks can change a dependency.
let desktops = self
.session
.lock()
.map_err(|_| anyhow::anyhow!("UI session poisoned"))?
.host_desktops();
// Shared intrinsic functions capture the primary desktop even when
// invoked from another window. Desktop bookkeeping is private host
// state; Window, viewport input and business dependencies remain.
reads.retain(|read| !desktops.contains(&read.object()));
cache.exclude_host_desktops(&desktops);
let (reads, names) = crate::presentation::split_reads(reads);
frame.focus = match vm.get_attr(desktop, "focus") {
Ok(Value::Number(id)) => id.as_i64().and_then(|n| u64::try_from(n).ok()),