Batch r2-2 review: a sole child passed over keeps the truncation marker

This commit is contained in:
bflatastic
2026-10-24 12:22:31 +07:00
parent f7f10bfc3b
commit e7f5877fdc
2 changed files with 8 additions and 1 deletions
+1 -1
View File
@@ -773,7 +773,7 @@ fn get_node(b: &mut dyn Backend, a: &Map<String, Value>) -> Result<ToolResult, S
"nextOffset": next,
})),
);
if window && next.is_none() && offset == 0 && used == depth && used_wire + MARKER_RESERVE <= budget {
if window && shown == total && offset == 0 && used == depth && used_wire + MARKER_RESERVE <= budget {
// Nothing was left out after all (an offset of zero that fitted whole).
out.as_object_mut().map(|o| o.remove("truncated"));
}
@@ -175,4 +175,11 @@ fn children_too_large_to_fit_page_one_at_a_time() {
assert!(pages <= 3);
}
assert_eq!(pages, 3);
// A sole child passed over still says the answer was cut.
let single = c.create(json!({"type": "frame", "x": 500, "y": 0, "width": 40, "height": 40}));
c.create(json!({"type": "rectangle", "parent": single, "x": 0, "y": 0, "width": 20, "height": 20, "name": "n".repeat(3000)}));
let (page, _) = get_node(&mut c, json!({"id": single, "depth": 1, "maxBytes": 2500}));
assert_eq!(page["children"].as_array().map_or(0, Vec::len), 0);
assert_eq!(page["truncated"]["children"]["total"], json!(1), "{}", page["truncated"]);
}