Compare commits

...
Author SHA1 Message Date
autocraft-bot[bot] f10e820dd6 Merge main (e7b67fb0) into the pull request
Resolved the conflicts in smartart.rs and tests.rs, but nothing was buil

Resolved the conflicts in smartart.rs and tests.rs, but nothing was built, tested or format-checked. In smartart.rs the layout, style and colors specs keep the PR's `→ {id, ids: ...}` text with main's `has_diagram` guard. In tests.rs both sides' tests are kept as separate #[test] functions. No conflict markers remain. The offline build can't fetch the craft-libs git dependency.
2026-12-02 19:31:36 +00:00
aiongg dd11c26ce0 Merge main into smartart-regenerated-ids 2026-11-05 04:36:47 +00:00
aiongg deed5990f8 Merge main into smartart-regenerated-ids 2026-11-05 04:23:51 +00:00
aiongg d5c1d46c29 Apply review fixes
- crates/engine/src/cmd/smartart/edit.rs
2026-11-05 03:57:17 +00:00
aiongg 0cae0572e5 Merge main into smartart-regenerated-ids 2026-11-05 03:49:04 +00:00
Zach BerryandClaude Opus 5.5 a22a9b75bc smartArt.colors, layout and style answer the regenerated graphic's {id, ids}
They regenerate the graphic's shapes with fresh ids but answered null, so an
agent had to inspect the slide to find them; they now answer {id, ids} as
insert.smartArt does. Split out of the SmartArt PR at review.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 20:10:30 -06:00
3 changed files with 46 additions and 6 deletions
+3 -3
View File
@@ -234,7 +234,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Change Layout",
["Diagram Design", "Layouts"],
None,
"{id?, kind: list|blockList|hBulletList|process|chevron|verticalProcess|stepUp|cycle|blockCycle|radial|hierarchy|pyramid|invertedPyramid|matrix|titledMatrix|pictureList|pictureCaption|pictureProcess|pictureHList|timeline|venn|target|textCycle|continuousCycle|horizontalHierarchy|gridMatrix|gear|funnel|segmentedCycle|multidirectionalCycle|orgChart|halfCircleOrgChart|cycleMatrix|segmentedPyramid|pie|nameTitleOrgChart|verticalBoxList|trapezoidList|tableList|accentProcess|continuousBlockProcess|bendingProcess|linearVenn|stackedVenn|nestedTarget}",
"{id?, kind: list|blockList|hBulletList|process|chevron|verticalProcess|stepUp|cycle|blockCycle|radial|hierarchy|pyramid|invertedPyramid|matrix|titledMatrix|pictureList|pictureCaption|pictureProcess|pictureHList|timeline|venn|target|textCycle|continuousCycle|horizontalHierarchy|gridMatrix|gear|funnel|segmentedCycle|multidirectionalCycle|orgChart|halfCircleOrgChart|cycleMatrix|segmentedPyramid|pie|nameTitleOrgChart|verticalBoxList|trapezoidList|tableList|accentProcess|continuousBlockProcess|bendingProcess|linearVenn|stackedVenn|nestedTarget} → {id, ids: the regenerated shapes}",
has_diagram,
change_layout
),
@@ -279,7 +279,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Diagram Styles",
["Diagram Design", "Diagram Styles"],
None,
"{id?, style: flat|subtle|intense|outline|polished|inset|cartoon|powder|brick}",
"{id?, style: flat|subtle|intense|outline|polished|inset|cartoon|powder|brick} → {id, ids: the regenerated shapes}",
has_diagram,
change_style
),
@@ -288,7 +288,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Change Colors",
["Diagram Design", "Diagram Styles"],
None,
"{id?, colors: colorful|range23|range34|range45|range56|accent1|…|accent6|accent1Grad|…|accent6Grad}",
"{id?, colors: colorful|range23|range34|range45|range56|accent1|…|accent6|accent1Grad|…|accent6Grad} → {id, ids: the regenerated shapes}",
has_diagram,
change_colors
),
+18 -3
View File
@@ -339,33 +339,47 @@ pub(super) fn set_picture(s: &mut Session, p: &Value) -> Result<Value> {
})
}
/// The answer of a command that regenerated a graphic's shapes: the group's id and its new children's ids.
fn regenerated(s: &Session, gid: ShapeId) -> Value {
let kids: Vec<u32> = match s.doc().ok().and_then(|st| st.shape(gid).map(|g| g.kind.clone())) {
Some(ShapeKind::Group { children, .. }) => children.iter().map(|c| c.id.0).collect(),
_ => vec![],
};
json!({"id": gid.0, "ids": kids})
}
pub(super) fn change_style(s: &mut Session, p: &Value) -> Result<Value> {
const CMD: &str = "smartArt.style";
let v = str_param(p, "style").filter(|k| STYLES.iter().any(|(id, _)| id == k)).ok_or_else(|| bad(CMD, "unknown style"))?.to_string();
let gid = target_group(s, p, CMD)?;
edit_diagram(s, p, CMD, |d| {
if d.style != v {
d.style_xml = None;
}
d.style = v;
Ok(Value::Null)
})
})?;
Ok(regenerated(s, gid))
}
pub(super) fn change_colors(s: &mut Session, p: &Value) -> Result<Value> {
const CMD: &str = "smartArt.colors";
let v = str_param(p, "colors").filter(|k| COLORS.iter().any(|(id, _)| id == k)).ok_or_else(|| bad(CMD, "unknown colours"))?.to_string();
let gid = target_group(s, p, CMD)?;
edit_diagram(s, p, CMD, |d| {
if d.colors != v {
d.colors_xml = None;
}
d.colors = v;
Ok(Value::Null)
})
})?;
Ok(regenerated(s, gid))
}
pub(super) fn change_layout(s: &mut Session, p: &Value) -> Result<Value> {
const CMD: &str = "smartArt.layout";
let kind = str_param(p, "kind").filter(|k| is_kind(k)).ok_or_else(|| bad(CMD, "unknown layout"))?.to_string();
let gid = target_group(s, p, CMD)?;
edit_diagram(s, p, CMD, |d| {
if d.kind != kind {
// PowerPoint's own layout no longer applies.
@@ -374,5 +388,6 @@ pub(super) fn change_layout(s: &mut Session, p: &Value) -> Result<Value> {
}
d.kind = kind;
Ok(Value::Null)
})
})?;
Ok(regenerated(s, gid))
}
+25
View File
@@ -7803,6 +7803,31 @@ fn save_to_image_path_is_an_error_not_zip_bytes() {
let _ = std::fs::remove_dir_all(&dir);
}
#[test]
fn smartart_colors_layout_and_style_answer_the_regenerated_ids() {
let mut s = session();
let r = s.execute("insert.smartArt", &json!({"kind": "process"})).unwrap();
let gid = r["id"].clone();
for (cmd, params) in [
("smartArt.colors", json!({"id": gid, "colors": "colorful"})),
("smartArt.layout", json!({"id": gid, "kind": "cycle"})),
("smartArt.style", json!({"id": gid, "style": "intense"})),
] {
let a = s.execute(cmd, &params).unwrap();
assert_eq!(a["id"], gid, "{cmd}: {a}");
let st = s.doc().unwrap();
let g = st
.doc
.slides
.iter()
.find_map(|sl| deckcraft_model::find_shape(&sl.shapes, deckcraft_model::ShapeId(gid.as_u64().unwrap() as u32)))
.unwrap();
let deckcraft_model::ShapeKind::Group { children, .. } = &g.kind else { panic!("group") };
let kids: Vec<u32> = children.iter().map(|c| c.id.0).collect();
assert_eq!(a["ids"], json!(kids), "{cmd}: {a}");
}
}
#[test]
fn unsupported_save_paths_are_refused_and_write_nothing() {
let dir = std::env::temp_dir().join(format!("deckcraft-save-ext-{}", std::process::id()));