From 1fdc52ce76944b8180f09bda4d4c895f89d8fc7d Mon Sep 17 00:00:00 2001 From: Zach Berry <1112351+zberry@users.noreply.github.com> Date: Wed, 4 Nov 2026 20:10:30 -0600 Subject: [PATCH 1/2] 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 --- crates/engine/src/cmd/smartart.rs | 6 +++--- crates/engine/src/cmd/smartart/edit.rs | 21 ++++++++++++++++++--- crates/engine/src/tests.rs | 25 +++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd/smartart.rs b/crates/engine/src/cmd/smartart.rs index 6083a9e73..df3621911 100644 --- a/crates/engine/src/cmd/smartart.rs +++ b/crates/engine/src/cmd/smartart.rs @@ -234,7 +234,7 @@ pub fn specs() -> Vec { "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 { "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 { "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 ), diff --git a/crates/engine/src/cmd/smartart/edit.rs b/crates/engine/src/cmd/smartart/edit.rs index 7c6b0b934..785950896 100644 --- a/crates/engine/src/cmd/smartart/edit.rs +++ b/crates/engine/src/cmd/smartart/edit.rs @@ -339,33 +339,47 @@ pub(super) fn set_picture(s: &mut Session, p: &Value) -> Result { }) } +/// The answer of a command that regenerated a graphic's shapes: `{id, ids}` as `insert.smartArt`. +fn regenerated(s: &Session, gid: ShapeId) -> Value { + let kids: Vec = 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 { 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 { 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 { 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 { } d.kind = kind; Ok(Value::Null) - }) + })?; + Ok(regenerated(s, gid)) } diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index efe5445a5..2dbad8fce 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -8220,3 +8220,28 @@ fn editor_replacements_report_autocorrection_and_cancel_only_the_open_session() assert!(std::sync::Arc::ptr_eq(&restored, &s.doc().unwrap().doc)); assert_eq!(s.doc().unwrap().history.undo.len(), undo); } + +#[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, ¶ms).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 = children.iter().map(|c| c.id.0).collect(); + assert_eq!(a["ids"], json!(kids), "{cmd}: {a}"); + } +} From 46b8dfa222745e0e2318ef95f071175a4607eaa5 Mon Sep 17 00:00:00 2001 From: aiongg <67543387+aiongg@users.noreply.github.com> Date: Thu, 5 Nov 2026 03:57:17 +0000 Subject: [PATCH 2/2] Apply review fixes - crates/engine/src/cmd/smartart/edit.rs --- crates/engine/src/cmd/smartart/edit.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/smartart/edit.rs b/crates/engine/src/cmd/smartart/edit.rs index 785950896..2e596eee3 100644 --- a/crates/engine/src/cmd/smartart/edit.rs +++ b/crates/engine/src/cmd/smartart/edit.rs @@ -339,7 +339,7 @@ pub(super) fn set_picture(s: &mut Session, p: &Value) -> Result { }) } -/// The answer of a command that regenerated a graphic's shapes: `{id, ids}` as `insert.smartArt`. +/// 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 = 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(),