fix(ui-patterns): the dock reports what it drew from the real run only

F1 memoizes the docked tree and its columns, and their views return what they drew. Measuring runs added to the
area's report as well: `Pass::dock` pushed each placed column, `shown_column` and `tree` added a view's returned
report, and an unmemoized column pushed its dividers. When the docks' split area measured them before showing them
(a new room or zoom), or the replay audit ran the tree, the report listed columns and sources twice, and the tree's
output differed from its replay (PhotoCraft tabs_tests under the audit, FW-365 F4).

Each of these is now an effect of the real run (`measure::effect`), as the group's own report already was. The trial
checks the counts the dock reports through room changes and under the audit.
This commit is contained in:
aiongg committed 2026-11-27 02:07:18 +00:00
1 parent 1cf70ccfae
commit eda8a40734
2 files changed
+41 -11

No files matched your search

+17 -8
View File
@@ -1617,8 +1617,11 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
// A docked column takes the dock's height, a stepped one (a tool rail) too: the references' docked
// toolbar keeps its column's surface down to the dock's foot, with the tools at the top
// (photocraft#16461). Content taller than the dock scrolls inside. Only a floating stepped window is as
// tall as its content.
self.report.placed.push(Placed { panel: first.clone(), rect: cell });
// tall as its content. A measuring run of the container around the dock places it too; the dock reports
// its columns from the pass's real run only, once.
if crate::runtime::measure::effect(ui.ctx(), "dock::placed_report") {
self.report.placed.push(Placed { panel: first.clone(), rect: cell });
}
let card = plan.cards.get(at).copied().flatten();
let place = ("docked", plan.edge, at);
let at = ColumnAt { cell, edge: plan.edge, bar: ColumnBar::Own, within: body.rect, open: plan.open.clone(), card };
@@ -1640,7 +1643,7 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
// The view's room is the column's cell, so the pointer over the cell, and nowhere else, runs it.
let drawn = ui.scope_builder(UiBuilder::new().max_rect(cell), |ui| MemoView::new(id, view, column_view::<P>).show(ui)).inner;
if let Some(drawn) = drawn {
self.add_drawn(drawn);
self.add_drawn(ui, drawn);
}
}
@@ -1655,7 +1658,7 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
let rail_footer = self.scene.rail_footer.cloned();
let view = TreeView { key, rail_footer, pass: &mut *self, at };
if let Some(drawn) = MemoView::new(id, view, tree_view::<P>).show(ui) {
self.add_drawn(drawn);
self.add_drawn(ui, drawn);
}
}
@@ -1788,8 +1791,12 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
}
}
/// Adds what a view drew, by its run or its replay, to the report.
fn add_drawn(&mut self, drawn: Drawn<P>) {
/// Adds what a view drew, by its run or its replay, to the report: in the pass's real run only. A measuring run's
/// replay returns the kept real run's report, which the real run adds once.
fn add_drawn(&mut self, ui: &Ui, drawn: Drawn<P>) {
if !crate::runtime::measure::effect(ui.ctx(), "dock::drawn_report") {
return;
}
self.report.sources.extend(drawn.sources);
self.report.shown.extend(drawn.shown);
self.report.placed.extend(drawn.placed);
@@ -1972,8 +1979,10 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
let output = shown.show_groups_at(ui, cell, |group, rect, ui, body| {
self.group_of(ui, body, group, GroupAt::Show(rect), in_window);
});
let dividers = output.dividers.into_iter().map(|(divider, rect, node)| DockSource::new(SourceKind::Divider(divider), rect, node));
self.report.sources.extend(dividers);
if crate::runtime::measure::effect(ui.ctx(), "dock::divider_report") {
let dividers = output.dividers.into_iter().map(|(divider, rect, node)| DockSource::new(SourceKind::Divider(divider), rect, node));
self.report.sources.extend(dividers);
}
let width = output.width.map(|width| width - inset);
ColumnWork { iconic: output.iconic, picked: output.picked, resized: output.resized, width, flyout: None }
};
+24 -3
View File
@@ -11,12 +11,12 @@ use craft_ui::docking::{DockConfig, DockPanels, PanelDrag, PanelSpec, PanelSpecs
use craft_ui::menu::PanelRow;
use craft_ui::patterns::dock::DockArea;
use craft_ui::runtime::drag;
use craft_ui::testing::in_audit_run;
use craft_ui::testing::pointer::{moved, press};
use craft_ui::testing::{
Fixture, MemoRun, last_frame_derived_builds, last_frame_memo_runs, last_pass_derived_builds, last_pass_memo_key_bytes, last_pass_memo_runs,
last_pass_runs, trial,
};
use craft_ui::testing::{audit_replays, in_audit_run};
use egui::{Pos2, Rect, Ui, Vec2};
use std::cell::{Cell, RefCell};
use std::rc::Rc;
@@ -574,6 +574,8 @@ struct VersionedDock {
versions: Rc<RefCell<Vec<u64>>>,
workspace: Rc<RefCell<Arc<Workspace<usize>>>>,
focused: Rc<RefCell<Vec<Option<usize>>>>,
/// How many docked columns and gesture sources each pass reported.
reported: Rc<RefCell<Vec<(usize, usize)>>>,
}
fn versioned_dock(layout: Layout<usize>) -> VersionedDock {
@@ -581,17 +583,19 @@ fn versioned_dock(layout: Layout<usize>) -> VersionedDock {
let versions = Rc::new(RefCell::new(vec![0; 32]));
let workspace = Rc::new(RefCell::new(Arc::new(Workspace::new(layout))));
let focused = Rc::new(RefCell::new(Vec::new()));
let reported = Rc::new(RefCell::new(Vec::new()));
let mut panels = Versioned { versions: Rc::clone(&versions) };
let (shown, seen) = (Rc::clone(&workspace), Rc::clone(&focused));
let (shown, seen, counts) = (Rc::clone(&workspace), Rc::clone(&focused), Rc::clone(&reported));
let mut fixture = Fixture::new(move |ui| {
let output = DockArea::new("Dock", Bind::bound(&mut *shown.borrow_mut()), &labels, &mut panels, DockConfig::default()).show(ui);
seen.borrow_mut().push(output.focused);
counts.borrow_mut().push((output.columns.len(), output.sources.len()));
});
fixture.room(Vec2::new(1200.0, 600.0)).settle().idle(SETTLE);
body_runs();
spec_reads();
focused.borrow_mut().clear();
VersionedDock { fixture, versions, workspace, focused }
VersionedDock { fixture, versions, workspace, focused, reported }
}
/// The dock's containers: what a settled dock whose panels all have versions runs none of.
@@ -676,3 +680,20 @@ fn a_replayed_group_reports_the_focus_it_holds() {
assert_eq!(runs_of(&fixture, &CONTAINERS), 0, "the focused dock replays");
assert!(focused.borrow().iter().all(|panel| *panel == Some(0)), "every replay reports the focus: {:?}", focused.borrow());
}
/// The docked tree and its columns report each column and gesture source once in every pass: when the replay audit
/// runs the tree in place of its replay, and when the docks' split area measures them before it shows them (a new
/// room).
#[trial]
fn a_measured_versioned_dock_reports_each_column_and_source_once() {
let VersionedDock { mut fixture, reported, .. } = versioned_dock(full(2));
let settled = *reported.borrow().last().expect("the dock reported");
assert_eq!(settled.0, 2, "the dock's two columns are placed");
audit_replays(fixture.ctx(), true);
reported.borrow_mut().clear();
fixture.idle(4);
audit_replays(fixture.ctx(), false);
fixture.room(Vec2::new(1100.0, 600.0)).idle(4).room(Vec2::new(1200.0, 640.0)).idle(4);
let reported = reported.borrow();
assert!(reported.iter().all(|counts| *counts == settled), "every pass reports {settled:?}: {reported:?}");
}