Skip to content

Editorial diagram design for Claude Code, Codex, GitHub Copilot, Cursor, Factory Droid, Qoder, and Pi. 45 diagram types. Self-contained HTML + SVG. No shadows. No Mermaid slop.

fix(import): report an outer Excalidraw group (#469)

Rudy Mizrahi Celekli84886ebcc163
diff --git a/scripts/verify-excalidraw-import.py b/scripts/verify-excalidraw-import.py
index e4b29d4..8426ee4 100644
--- a/scripts/verify-excalidraw-import.py
+++ b/scripts/verify-excalidraw-import.py
@@ -187,6 +187,56 @@ def check_whiteboard() -> None:
ok("whiteboard parses: shapes, frames, bound labels, groups, cycle, ledger")
+def check_nested_groups(tmp: Path) -> None:
+ # Excalidraw orders ids deepest to shallowest: the inner group comes first.
+ # Members of that inner group still belong to each outer group.
+ board = tmp / "nested-groups.excalidraw"
+ board.write_text(
+ scene(
+ "nested-groups",
+ [
+ {
+ "id": "a",
+ "type": "rectangle",
+ "x": 0,
+ "y": 0,
+ "width": 40,
+ "height": 40,
+ "groupIds": ["inner", "outer"],
+ },
+ {
+ "id": "b",
+ "type": "rectangle",
+ "x": 50,
+ "y": 0,
+ "width": 40,
+ "height": 40,
+ "groupIds": ["inner", "outer"],
+ },
+ {
+ "id": "c",
+ "type": "rectangle",
+ "x": 100,
+ "y": 0,
+ "width": 40,
+ "height": 40,
+ "groupIds": ["outer"],
+ },
+ ],
+ ),
+ encoding="utf-8",
+ )
+ groups = {
+ group["id"]: group["children"]
+ for group in json.loads(run_extract([str(board), "--json"]))["scene"]["analysis"][
+ "collapsible_groups"
+ ]
+ }
+ if groups.get("inner") != 2 or groups.get("outer") != 3:
+ fail(f"nested Excalidraw groups were not both reported: {groups}")
+ ok("nested groups keep the outer cluster and the inner cluster")
+
+
def check_bindings_and_shapes(tmp: Path) -> None:
board = tmp / "bindings.excalidraw"
board.write_text(
@@ -773,6 +823,7 @@ def main() -> int:
check_json_nesting_diagnostic(tmp)
check_unimported_container_text(tmp)
check_whiteboard()
+ check_nested_groups(tmp)
check_bindings_and_shapes(tmp)
check_arrow_directions(tmp)
check_bidirectional_cycle(tmp)
diff --git a/skills/diagram-design/references/import-excalidraw.md b/skills/diagram-design/references/import-excalidraw.md
index a03dfdb..7ac1695 100644
--- a/skills/diagram-design/references/import-excalidraw.md
+++ b/skills/diagram-design/references/import-excalidraw.md
@@ -24,7 +24,7 @@ The extractor parses bounded JSON. It **never renders, fetches, or executes** th
Element IDs must be unique throughout the scene's `elements` array, including deleted elements. If the extractor reports `duplicate element id`, remove or reassign the duplicate in the source—or re-export the scene—then retry.
-What the extractor maps: rectangles, ellipses, and diamonds become nodes; arrows and lines become edges (arrowheads set direction; `strokeStyle` keeps dashed semantics); bound text folds into its node or edge label; frames become containers with their members; groups are reported as collapsible clusters; standalone text stays a floating `text` node. Text bound to an unsupported or discarded container remains a standalone text node instead of disappearing with that container. Freedraw strokes, image pixels, embeds, links, deleted elements, and unknown element types are counted into the `discarded:` line for the fidelity ledger. The digest mirrors the draw.io and Mermaid IR: canvas bounds, nodes/edges/containers, depth and cycles, shapes, type candidates, budget flags, hubs, entries, terminals, unconnected nodes, collapsible groups, and tables.
+What the extractor maps: rectangles, ellipses, and diamonds become nodes; arrows and lines become edges (arrowheads set direction; `strokeStyle` keeps dashed semantics); bound text folds into its node or edge label; frames become containers with their members; explicit groups with at least two members are considered as collapse candidates, including an outer group whose members also belong to a tighter group; only the first eight sorted candidates (including frame candidates) are reported in the digest and JSON; standalone text stays a floating `text` node. Text bound to an unsupported or discarded container remains a standalone text node instead of disappearing with that container. Freedraw strokes, image pixels, embeds, links, deleted elements, and unknown element types are counted into the `discarded:` line for the fidelity ledger. The digest mirrors the draw.io and Mermaid IR: canvas bounds, nodes/edges/containers, depth and cycles, shapes, type candidates, budget flags, hubs, entries, terminals, unconnected nodes, collapsible groups, and tables.
- `--json` emits the full IR when the digest truncated something you need.
- `--max-rows N` controls digest table length; default 40.
diff --git a/skills/diagram-design/scripts/excalidraw_extract.py b/skills/diagram-design/scripts/excalidraw_extract.py
index 6b57876..c53c3b6 100644
--- a/skills/diagram-design/scripts/excalidraw_extract.py
+++ b/skills/diagram-design/scripts/excalidraw_extract.py
@@ -476,10 +476,16 @@ def analyze(scene: Scene) -> dict[str, Any]:
if container.children
and all(not scene.node_map[child].children for child in container.children)
]
+ # Excalidraw orders group ids from deepest to shallowest (inner to outer).
+ # Count every membership: selecting either endpoint alone loses a cluster.
group_members: dict[str, list[Node]] = {}
for node in nodes:
- if node.groups:
- group_members.setdefault(node.groups[-1], []).append(node)
+ seen_groups: set[str] = set()
+ for group_id in node.groups:
+ if not group_id or group_id in seen_groups:
+ continue
+ seen_groups.add(group_id)
+ group_members.setdefault(group_id, []).append(node)
for group_id, members in group_members.items():
if len(members) < 2:
continue