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): skip draw.io cells hidden with visible=0 (#444)

Rudy Mizrahi Celekli15d44aed0985
diff --git a/scripts/verify-drawio-import.py b/scripts/verify-drawio-import.py
index 0e7cfdf..6053378 100644
--- a/scripts/verify-drawio-import.py
+++ b/scripts/verify-drawio-import.py
@@ -400,6 +400,53 @@ def check_bom_prefixed(tmp: Path) -> None:
ok("UTF-8 BOM-prefixed raw XML and bare compressed payload parse like their unprefixed input")
+def check_hidden_cells(tmp: Path) -> None:
+ # visible="0" on a cell, a group, or a layer hides it in draw.io; the import must not resurrect it.
+ def vertex(cid: str, parent: str, x: int, extra: str = "") -> str:
+ return (f'<mxCell id="{cid}" value="{cid.upper()}" vertex="1" parent="{parent}"{extra}>'
+ f'<mxGeometry x="{x}" width="60" height="40" as="geometry"/></mxCell>')
+
+ def edge(cid: str, parent: str, extra: str = "") -> str:
+ return (f'<mxCell id="{cid}" value="{cid}" edge="1" parent="{parent}" source="a" target="b"{extra}>'
+ '<mxGeometry relative="1" as="geometry"/></mxCell>')
+
+ source = tmp / "hidden-cells.drawio"
+ source.write_text(
+ '<mxGraphModel><root><mxCell id="0"/><mxCell id="1" parent="0"/>'
+ '<mxCell id="layer2" value="Draft" parent="0" visible="0"/>'
+ + vertex("a", "1", 0) + vertex("b", "1", 100)
+ + vertex("hidden", "1", 200, ' visible="0"')
+ + vertex("draft", "layer2", 300)
+ + vertex("grp", "1", 400, ' visible="0"') + vertex("inside", "grp", 5)
+ + edge("shown", "1") + edge("hiddenedge", "1", ' visible="0"') + edge("draftedge", "layer2")
+ + "</root></mxGraphModel>",
+ encoding="utf-8",
+ )
+ page = json.loads(run_extract([str(source), "--json"]))["pages"][0]
+ nodes, edges = sorted(n["id"] for n in page["nodes"]), sorted(e["id"] for e in page["edges"])
+ if (nodes, edges) != (["a", "b"], ["shown"]):
+ fail(f"hidden cells, groups or layers leaked into the IR: nodes={nodes} edges={edges}")
+ # Put the deepest descendant first: memoization cannot shorten the first
+ # ancestor walk, and input order must not resurrect a hidden descendant.
+ deep = tmp / "hidden-child-first.drawio"
+ count = 8000
+ deep.write_text(
+ '<mxGraphModel><root>'
+ + ''.join(
+ f'<mxCell id="n{i}" parent="n{i + 1}" vertex="1"'
+ + (' visible="0"' if i == count - 1 else '')
+ + '><mxGeometry x="0" y="0" width="40" height="40" as="geometry"/></mxCell>'
+ for i in range(count)
+ )
+ + '</root></mxGraphModel>',
+ encoding="utf-8",
+ )
+ deep_page = json.loads(run_extract([str(deep), "--json"]))["pages"][0]
+ if deep_page["nodes"] or deep_page["edges"]:
+ fail("Child-first deep descendants escaped their hidden ancestor")
+ ok("cells hidden directly, through a group, or through a layer are dropped from the IR")
+
+
def check_containers(tmp: Path) -> None:
model = re.search(
r"<mxGraphModel.*?</mxGraphModel>", FIXTURE.read_text(encoding="utf-8"), re.S
@@ -843,6 +890,7 @@ def main() -> int:
check_nested_geometry(tmp)
check_nested_relative_geometry(tmp)
check_bom_prefixed(tmp)
+ check_hidden_cells(tmp)
check_containers(tmp)
check_legacy_stdout_encoding(tmp)
check_out_write_errors(tmp)
diff --git a/skills/diagram-design/references/import-drawio.md b/skills/diagram-design/references/import-drawio.md
index 18d4567..67c7607 100644
--- a/skills/diagram-design/references/import-drawio.md
+++ b/skills/diagram-design/references/import-drawio.md
@@ -28,6 +28,8 @@ Relationship direction follows the serialized arrowheads: a start-only arrow rev
Absolute IR geometry resolves relative child vertices using their parent width/height and encoded `mxPoint` offset; ordinary pixel-positioned children retain their original coordinate semantics. Parent dimensions are resolved independently of cell order, and nonfinite offsets or overflow remain named failures.
+Cells hidden in draw.io (`visible="0"` on a cell, a group, or a layer) are not part of the diagram: the extractor skips them together with everything parented beneath them, so hidden drafts never reach the digest or the IR.
+
Each import is limited to 100 direct `<diagram>` pages and 10,000 direct children under a page's `<root>`. The extractor exits with `page limit exceeded (max 100)` or `page N: cell limit exceeded (max 10000)`, respectively. If either limit is reached, split the source into smaller draw.io files and retry.
Options worth knowing:
diff --git a/skills/diagram-design/scripts/drawio_extract.py b/skills/diagram-design/scripts/drawio_extract.py
index 99c499c..ea3a4ef 100644
--- a/skills/diagram-design/scripts/drawio_extract.py
+++ b/skills/diagram-design/scripts/drawio_extract.py
@@ -416,6 +416,28 @@ def parse_page(diagram: ET.Element, index: int) -> Page:
raw[cid] = {"cell": cell, "attrs": attrs, "value": value}
order.append(cid)
+ # draw.io hides a cell, a group or a whole layer with visible="0"; what the author hid is not
+ # part of the diagram, so drop it together with everything parented beneath it.
+ hidden: dict[str, bool] = {}
+
+ def is_hidden(cid: str) -> bool:
+ chain: list[str] = []
+ visited: set[str] = set()
+ current, result = cid, False
+ while current in raw and current not in visited:
+ if current in hidden:
+ result = hidden[current]
+ break
+ chain.append(current)
+ visited.add(current)
+ if raw[current]["cell"].get("visible") == "0":
+ result = True
+ break
+ current = raw[current]["cell"].get("parent") or ""
+ for seen in chain:
+ hidden[seen] = result
+ return result
+
# Pass 2: vertices (absolute geometry resolved after the pass).
edge_label_parts: dict[str, list[str]] = {}
relative_offsets: dict[str, tuple[float, float]] = {}
@@ -424,7 +446,7 @@ def parse_page(diagram: ET.Element, index: int) -> Page:
cell = entry["cell"]
style = parse_style(cell.get("style"))
parent = cell.get("parent")
- if cell.get("edge") == "1":
+ if is_hidden(cid) or cell.get("edge") == "1":
continue
if cell.get("vertex") != "1":
continue
@@ -514,7 +536,7 @@ def parse_page(diagram: ET.Element, index: int) -> Page:
for cid in order:
entry = raw[cid]
cell = entry["cell"]
- if cell.get("edge") != "1":
+ if is_hidden(cid) or cell.get("edge") != "1":
continue
style = parse_style(cell.get("style"))
geom = cell.find("mxGeometry")