Skip to content

feat(drawio): infer shape person on re-import for round-trip fidelity#2685

Merged
davydkov merged 3 commits intolikec4:mainfrom
sraphaz:feat/drawio-infer-shape-person-roundtrip
Mar 6, 2026
Merged

feat(drawio): infer shape person on re-import for round-trip fidelity#2685
davydkov merged 3 commits intolikec4:mainfrom
sraphaz:feat/drawio-infer-shape-person-roundtrip

Conversation

@sraphaz
Copy link
Copy Markdown
Collaborator

@sraphaz sraphaz commented Mar 4, 2026

feat(drawio): infer shape person on re-import for round-trip fidelity

Summary

Follow-up to the Draw.io person-shape fix (upstream PR #2682). That PR changes export to use shape=actor instead of shape=umlActor for LikeC4 shape person and updates the parser so inferKind recognizes shape=actor as actor. This PR adds round-trip fidelity on the import side: re-imported actor cells now get an explicit style { shape person } in the emitted .c4 source, so the round-trip is symmetric (export: person → shape=actor; import: shape=actor → actor with shape person).

Changes

  • packages/generators/src/drawio/parse-drawio.ts

    • inferKind() now treats shape=actor as actor (alongside umlactor and shape=person), so cells exported with the current Draw.io format are emitted as actor 'title' rather than container. Keeps this PR self-contained and CI green whether or not #2682 is merged first.
    • inferShape() now returns 'person' when the DrawIO cell style contains shape=actor, shape=person, or umlactor. Existing logic for cylinder, document, and rectangle is unchanged.
  • packages/generators/src/drawio/parse-drawio.spec.ts
    New test: "parse DrawIO to LikeC4 - vertex with shape=actor emits actor with style { shape person } for round-trip fidelity" (minimal diagram with one vertex style="shape=actor;..."). Asserts that the output contains actor 'User' and shape person, and snapshot updated.

  • .changeset/drawio-infer-shape-person-roundtrip.md
    Patch changeset for @likec4/generators.

Why

After #2682, re-importing a .drawio that contains an actor (with shape=actor) already yields name = actor 'title' and renders correctly, because actor implies the person shape by default. This PR only makes the emitted source explicit: the .c4 file will include style { shape person } for those elements, so the round-trip is fully symmetric and the source faithfully reflects the diagram.

Checklist

  • Change is minimal and focused on round-trip shape fidelity
  • Tests added/updated: parse-drawio.spec.ts + snapshot
  • Tests run: pnpm test -- packages/generators/src/drawio/parse-drawio.spec.ts (or from repo root with vitest and node_modules/.bin in PATH)
  • Changeset included for @likec4/generators (patch)
  • Commit follows conventional style (feat(drawio): ...)
  • CI passes on this branch (verified on fork: sraphaz/likec4#26)

Merge order

Safe to merge before or after #2682. Can be proposed to upstream after #2682 is merged, or in parallel at maintainers’.

Summary by CodeRabbit

  • New Features

    • Improved Draw.io import/export handling so actor/person shapes are recognized and preserved, enabling symmetric round-trips between export and re-import.
  • Tests

    • Added test coverage validating actor/person shape round-tripping to ensure consistent labels and styles after import/export cycles.

sraphaz added 2 commits March 4, 2026 13:08
inferShape() now returns 'person' when DrawIO cell style contains shape=actor, shape=person, or umlactor. Re-imported actor cells get explicit style { shape person } in emitted .c4.

Made-with: Cursor
inferKind() now includes shape=actor so vertex with shape=actor is emitted as actor (not container). Aligns with upstream likec4#2682 and makes this branch pass ci:test without depending on likec4#2682 merge.

Made-with: Cursor
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 4, 2026

🦋 Changeset detected

Latest commit: 03eb4b2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
@likec4/generators Patch
@likec4/playground Patch
@likec4/language-services Patch
likec4 Patch
@likec4/vite-plugin Patch
likec4-vscode Patch
@likec4/docs-astro Patch
@likec4/style-preset Patch
@likec4/styles Patch
@likec4/config Patch
@likec4/core Patch
@likec4/diagram Patch
@likec4/language-server Patch
@likec4/layouts Patch
@likec4/log Patch
@likec4/mcp Patch
@likec4/react Patch
@likec4/tsconfig Patch
@likec4/vscode-preview Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@sraphaz
Copy link
Copy Markdown
Collaborator Author

sraphaz commented Mar 4, 2026

Hi @davydkov, when you have a moment, could you take a look at this PR? It's an optional follow-up to #2682 (round-trip with explicit \shape person\ on import). Thanks.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ffca6785-c0bd-42f8-ae6b-92a3ca569d80

📥 Commits

Reviewing files that changed from the base of the PR and between 71ab678 and 03eb4b2.

📒 Files selected for processing (2)
  • .changeset/drawio-infer-shape-person-roundtrip.md
  • packages/generators/src/drawio/parse-drawio.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/drawio-infer-shape-person-roundtrip.md

📝 Walkthrough

Walkthrough

Extends Draw.io import inference to treat shape=actor, shape=person, and umlactor as actor elements and map them to the LikeC4 person shape, enabling symmetric round-tripping between exported shape=actor and re-imported actor elements with explicit shape person styling.

Changes

Cohort / File(s) Summary
Changelog
\.changeset/drawio-infer-shape-person-roundtrip.md
Adds changelog entry documenting expanded Draw.io shape inference for actor/person round-tripping.
Parser Logic
packages/generators/src/drawio/parse-drawio.ts
Updates inference to recognize shape=actor, shape=person, and umlactor as actor/person, mapping them to LikeC4 person shape.
Test Coverage
packages/generators/src/drawio/parse-drawio.spec.ts
Adds fixture and test verifying a Draw.io vertex with shape=actor is parsed/emitted as an actor labeled and styled with shape person, including snapshot assertion.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I munch a vertex, soft and round,
Actor becomes person, tidy and sound.
Back and forth we hop and play,
Shapes find home, and here they stay. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title precisely describes the main change: extending Draw.io shape inference for 'person' on re-import to achieve round-trip fidelity.
Description check ✅ Passed The PR description is comprehensive, covering summary, specific changes, rationale, and checklist items. It substantially exceeds the template requirements while remaining well-organized.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/drawio-infer-shape-person-roundtrip.md:
- Line 7: The changelog text incorrectly asserts the exporter uses `shape=actor`
when the current exporter emits `shape=umlActor`; update the sentence in
.changeset/drawio-infer-shape-person-roundtrip.md so it reflects both possible
export values (e.g., "person → shape=actor or shape=umlActor") and keep the
import wording about inferKind() and inferShape() as-is; reference the symbols
inferKind() and inferShape() in the note so readers can correlate the behavior
with those functions.

In `@packages/generators/src/drawio/parse-drawio.ts`:
- Around line 580-581: The comment above the actor/person shape check is
outdated; update the comment near the conditional that checks
s.includes('shape=actor') || s.includes('shape=person') ||
s.includes('umlactor') to mention that the exporter may emit shape=actor,
shape=person, shape=umlactor or shape=umlActor (current generator emits
shape=umlActor), so document both legacy and current forms to avoid stale
behavior claims.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6079b160-37fc-4541-b14f-210119d17492

📥 Commits

Reviewing files that changed from the base of the PR and between b381f8a and 71ab678.

⛔ Files ignored due to path filters (1)
  • packages/generators/src/drawio/__snapshots__/parse-drawio.spec.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (3)
  • .changeset/drawio-infer-shape-person-roundtrip.md
  • packages/generators/src/drawio/parse-drawio.spec.ts
  • packages/generators/src/drawio/parse-drawio.ts

…e=actor or umlActor)

CodeRabbit: changeset now states export may emit shape=actor or shape=umlActor; inferShape comment updated to match.
Made-with: Cursor
@sraphaz
Copy link
Copy Markdown
Collaborator Author

sraphaz commented Mar 4, 2026

Addressed CodeRabbit's review: commit 03eb4b2 updates the changeset wording and the \inferShape\ comment so both reflect that the exporter may use \shape=actor\ or \shape=umlActor. Replied on the two inline comments.

@davydkov davydkov merged commit a80d2e8 into likec4:main Mar 6, 2026
13 checks passed
@likec4-ci likec4-ci bot mentioned this pull request Mar 6, 2026
@likec4-ci likec4-ci bot mentioned this pull request Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants