fix(orchestrator): stabilize radial repair checks

This commit is contained in:
Kayshen-X 2026-07-15 22:47:18 +08:00
parent 0635927c42
commit a37d9a8d3d
4 changed files with 22 additions and 7 deletions

View file

@ -1,3 +1,5 @@
#![recursion_limit = "256"]
//! `op-orchestrator` — S3a 设计编排器(单屏顺序骨架)。
//!
//! 把 TS `apps/web/src/services/ai/orchestrator.ts` 的阶段 1-4

View file

@ -79,6 +79,9 @@ fn canonical_fixed_ring() -> Value {
}
fn find_id<'a>(value: &'a Value, id: &str) -> Option<&'a Value> {
if let Some(values) = value.as_array() {
return values.iter().find_map(|value| find_id(value, id));
}
if value.get("id").and_then(Value::as_str) == Some(id) {
return Some(value);
}
@ -378,7 +381,11 @@ fn missing_centre_layout_is_measured_as_the_jian_default_row() {
width > height,
"default row measurement must be wider than tall"
);
assert!(!check_generated_nodes(&nodes, 390.0).has_fatal());
let after = check_generated_nodes(&nodes, 390.0);
assert!(
!after.has_fatal(),
"repaired default-row centre must pass self-check: {after:?}; repaired={repaired}"
);
}
#[test]

View file

@ -119,15 +119,21 @@ fn authored_radial_patch(v: &Value) -> Option<AuthoredRadialPatch> {
if !valid_size(width, height) {
return None;
}
if !is_arc_ellipse(child) && (width > geometry.parent_w || height > geometry.parent_h) {
let width_patch = (!has_numeric(child, "width")).then_some(width.round());
let height_patch = (!has_numeric(child, "height")).then_some(height.round());
let positioned_width = width_patch.unwrap_or(width);
let positioned_height = height_patch.unwrap_or(height);
if !is_arc_ellipse(child)
&& (positioned_width > geometry.parent_w || positioned_height > geometry.parent_h)
{
return None;
}
patches.push(AuthoredChildPatch {
index,
x: ((geometry.parent_w - width) / 2.0).round(),
y: ((geometry.parent_h - height) / 2.0).round(),
width: (!has_numeric(child, "width")).then_some(width.round()),
height: (!has_numeric(child, "height")).then_some(height.round()),
x: ((geometry.parent_w - positioned_width) / 2.0).round(),
y: ((geometry.parent_h - positioned_height) / 2.0).round(),
width: width_patch,
height: height_patch,
});
}
Some(AuthoredRadialPatch {

View file

@ -198,7 +198,7 @@ fn cleanup_recenters_radial_stack_after_geometry_changes_wrapper_width() {
"layout":"vertical","padding":[0,24],"children":[
{"type":"frame","id":"card","name":"Activity Card","width":"fill_container",
"height":"fit_content","layout":"vertical","padding":20,"gap":20,"children":[
{"type":"frame","id":"ring","name":"Ring","width":320,"height":120,
{"type":"frame","id":"ring","name":"Ring","width":360,"height":120,
"layout":"horizontal","gap":0,"alignItems":"center","justifyContent":"center","children":[
{"type":"ellipse","id":"track","name":"Ring Track","width":120,"height":120,
"innerRadius":0.86},