Skip to content

feat: DrawIO export (CLI, Playground, round-trip) + cleanup#22

Merged
sraphaz merged 6 commits intomainfrom
feat/drawio-export
Feb 14, 2026
Merged

feat: DrawIO export (CLI, Playground, round-trip) + cleanup#22
sraphaz merged 6 commits intomainfrom
feat/drawio-export

Conversation

@sraphaz
Copy link
Copy Markdown
Owner

@sraphaz sraphaz commented Feb 14, 2026

Summary

This PR adds DrawIO (draw.io) export to LikeC4: export views to .drawio XML (single or multi-file), with optional round-trip options (layout, stroke colors/widths, edge waypoints), CLI command, and Playground context menu integration. It also includes a cleanup pass: removal of build artifacts that were accidentally committed, and addressing CodeRabbit review (actionable fixes + nitpicks).


Features

Export to DrawIO

  • @likec4/generators: generateDrawio, generateDrawioMulti produce draw.io-compatible XML; optional GenerateDrawioOptions for layout override, stroke colors/widths per node, edge waypoints, and round-trip comment blocks in source.
  • Round-trip: Export can embed // likec4.layout.viewId, // likec4.strokeColor, // likec4.strokeWidth, // likec4.edge.waypoints in .c4 source; parseDrawioRoundtripComments reads them for re-export after editing in draw.io.
  • CLI: likec4 export drawio <path> -o <outdir> with options --all-in-one, --roundtrip, --uncompressed, --project, --use-dot.
  • Playground: Right-click on diagram canvas → “Export to DrawIO” (current view) or “Export all” (all views). Optional getSourceContent for round-trip when used outside the provider.

Tests & E2E

  • Unit: generate-drawio.spec.ts, drawio-demo-export-import.spec.ts (cloud-system demo, element/edge counts, loadable XML). Timeouts increased for fromWorkspace/layoutedModel tests.
  • E2E: Playwright tests for DrawIO context menu in Playground (pnpm test:playground from e2e/).

Cleanup & CodeRabbit fixes

Build artifacts removal

  • Removed ~1555 compiled .js/.d.ts and PR temp docs that had been added in a previous commit (git add -A). All were verified to match strict criteria (only artifacts).
  • .gitignore updated: *.spec.js, *.test.js, apps/playground/src/**/*.js, packages/*/src/**/*.js, .cursor/, and comments on scope.

Actionable (CodeRabbit)

  • packages/config filenames: isLikeC4Config / isLikeC4NonJsonConfig return boolean instead of type predicates (they only check basename; narrowing full path was unsound).
  • .cursor/: Directory gitignored; git-push-remotes.mdc removed from tracking. AGENTS.md notes that contributors may use .cursor/rules/ locally and should not commit it.
  • pako: pako and @types/pako added to pnpm workspace catalog; packages/generators uses catalog:.
  • parse-drawio: In computeContainerTitles, title cells are created with parent="${containerId}" by the generator; parse logic now uses v.parent === cont.id instead of v.parent === cont.parent. Self-closing tag detection uses full trimmed open tag. TODO added for round-trip comment parser deduplication.
  • logger: ViteLogger type now omits both debug and hasErrorLogged so they are optional for Vite.
  • ci-validate-in-docker: NODE_ENV=production moved to after pnpm install so devDependencies are installed; Corepack pnpm set to 10.29.3 (match .tool-versions); comment added for version sync.
  • vitest: Root config merges configDefaults.exclude with custom patterns so default exclusions are preserved.

Nitpicks

  • Scripts: ci-validate-in-docker.ps1 uses Write-Output instead of Write-Host.
  • documentation-provider: Null guards for parseDeploymentNode and parseDeployedInstance (aligned with parseElement).
  • JSDoc: HoverProvider (class + constructor), browser startLanguageServer, drawio handler (sequential export comment).
  • Playground: useDrawioContextMenuActions — pass onExportError directly; comment on stabilizing viewStates for useMemo. Monaco: pass setLayoutedModelApi directly. LanguageClientSync: logger.warn in catch blocks for layouted model / layout view failures.
  • generate-drawio: Removed duplicate html=1; at end of vertex style; comments for getDefaultStrokeWidth and node sort. generate-drawio.spec: Comment on duplication with drawio-test-utils; mockViewModel as plain function (no vi.fn). e2e: Removed redundant $.nothrow = false; simplified assertion message (dead branch). .gitignore: Comments on glob scope and personal workflow files.

Changesets

  • drawio-related changesets are in .changeset/ (e.g. drawio-cli-roundtrip-e2e, drawio-roundtrip-options, drawio-import-postpack).

Checklist

  • Build and typecheck pass
  • Tests updated/added (unit + e2e)
  • CodeRabbit actionable and nitpick comments addressed
  • No build artifacts or personal config committed

Summary by CodeRabbit

  • Bug Fixes

    • Improved error logging in drawio export and layout operations with contextual messages
    • Enhanced error handling in language server to prevent null/undefined failures
    • Fixed container-title resolution in drawio parsing
  • Documentation

    • Added clarification comments for build and development configurations
  • Tests

    • Updated test timeout configurations for improved reliability
  • Chores

    • Updated dependency catalog references
    • Refined build and development server configurations with custom logger support
    • Enhanced development server filesystem access controls

- config/filenames: isLikeC4Config/isLikeC4NonJsonConfig return boolean (no unsound type predicates)
- .cursor/ gitignored, removed from tracking; AGENTS.md note for contributors
- pako + @types/pako in pnpm catalog; generators use catalog:
- parse-drawio: computeContainerTitles v.parent === cont.id; self-closing tag trim; TODO roundtrip
- drawio-demo-export-import.spec: timeout 20s for fromWorkspace/layoutedModel tests
- logger: ViteLogger Omit hasErrorLogged
- ci-validate-in-docker: NODE_ENV after install; pnpm 10.29.3; version comment
- vitest: configDefaults.exclude merged
- Nitpicks: Write-Output, null checks (documentation-provider), JSDoc (HoverProvider, browser, handler), useDrawioContextMenuActions/Monaco/LanguageClientSync simplifications, generate-drawio html=1/sort comments, generate-drawio.spec duplication note + plain mockViewModel, e2e dead branch + $.nothrow, .gitignore comments

Co-authored-by: Cursor <[email protected]>
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 14, 2026

Warning

Rate limit exceeded

@sraphaz has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 32 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

This PR consolidates cleanup and improvements across the codebase: removes cursor configuration documentation, updates gitignore patterns, simplifies type signatures for config functions, improves error logging in draw.io and language server components, standardizes dependency management via pnpm catalog, adds Logger type casting in Vite configurations, and updates CI scripts and test configurations.

Changes

Cohort / File(s) Summary
Git & Cursor Configuration
.cursor/rules/git-push-remotes.mdc, .gitignore, AGENTS.md
Deleted git-push remotes documentation, added .cursor/ to gitignore, and documented that .cursor/ rules should remain local and not committed.
Type System & Public API
packages/config/src/filenames.ts, packages/likec4/src/logger.ts
Changed isLikeC4Config and isLikeC4NonJsonConfig from type predicates to boolean returns; made ViteLogger treat debug and hasErrorLogged as optional properties.
Draw.io Parser & Generator
packages/generators/src/drawio/parse-drawio.ts, packages/generators/src/drawio/generate-drawio.ts, packages/generators/src/drawio/generate-drawio.spec.ts
Improved self-closing tag detection in mxCell parsing, fixed container-title resolution logic, removed redundant html=1 style rule, removed mock function wrapper in tests.
Error Handling & Logging
apps/playground/src/monaco/LanguageClientSync.tsx, packages/language-server/src/documentation/documentation-provider.ts, packages/language-server/src/lsp/HoverProvider.ts, packages/likec4/src/cli/export/drawio/handler.ts
Added explicit error logging with contextual messages in layout operations, added null/undefined guards for parser results, added JSDoc documentation for classes and functions.
Vite Configuration
packages/likec4/src/vite/config-app.ts, packages/likec4/src/vite/config-app.prod.ts, packages/likec4/src/vite/vite-build.ts, packages/likec4/src/vite/vite-preview.ts, packages/likec4/src/vite/vite-dev.ts
Added Logger type import and customLogger type casting across config files; introduced explicit fs.allow and fs.deny arrays in dev server configuration.
Dependency Management
packages/generators/package.json, pnpm-workspace.yaml
Updated pako and @types/pako dependencies to use catalog-based specifiers and added them to pnpm catalog.
Testing & E2E
e2e/src/likec4-cli-export-drawio.spec.ts, e2e/tests/drawio-playground.spec.ts, packages/likec4/src/drawio-demo-export-import.spec.ts, vitest.config.ts
Removed global zx nothrow configuration, simplified assertion messages, added Download type import, refactored test timeout syntax, replaced hardcoded exclude patterns with configDefaults.
Infrastructure & Scripts
scripts/ci-validate-in-docker.ps1, scripts/ci-validate-in-docker.sh
Replaced Write-Host with Write-Output in PowerShell script; updated pnpm version to 10.29.3, moved NODE_ENV assignment, added e2e typecheck step, and success message in bash script.
Documentation
packages/language-server/src/browser/index.ts, apps/playground/src/components/drawio/useDrawioContextMenuActions.ts
Added JSDoc comment for startLanguageServer function; added comment noting that callers should stabilize viewStates for memo effectiveness.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 A cursor rule hops away, gitignores grow wide,
Vite loggers now typed, with customLogger pride,
Draw.io tags parse with a fix and a flair,
Errors get logged where they're meant to be snared!

🚥 Pre-merge checks | ✅ 2 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (27 files):

⚔️ .gitignore (content)
⚔️ AGENTS.md (content)
⚔️ apps/playground/src/components/drawio/useDrawioContextMenuActions.ts (content)
⚔️ apps/playground/src/monaco/LanguageClientSync.tsx (content)
⚔️ e2e/src/likec4-cli-export-drawio.spec.ts (content)
⚔️ e2e/tests/drawio-playground.spec.ts (content)
⚔️ packages/config/src/filenames.ts (content)
⚔️ packages/generators/package.json (content)
⚔️ packages/generators/src/drawio/generate-drawio.spec.ts (content)
⚔️ packages/generators/src/drawio/generate-drawio.ts (content)
⚔️ packages/generators/src/drawio/parse-drawio.ts (content)
⚔️ packages/language-server/src/browser/index.ts (content)
⚔️ packages/language-server/src/documentation/documentation-provider.ts (content)
⚔️ packages/language-server/src/lsp/HoverProvider.ts (content)
⚔️ packages/likec4/src/cli/export/drawio/handler.ts (content)
⚔️ packages/likec4/src/drawio-demo-export-import.spec.ts (content)
⚔️ packages/likec4/src/logger.ts (content)
⚔️ packages/likec4/src/vite/config-app.prod.ts (content)
⚔️ packages/likec4/src/vite/config-app.ts (content)
⚔️ packages/likec4/src/vite/vite-build.ts (content)
⚔️ packages/likec4/src/vite/vite-dev.ts (content)
⚔️ packages/likec4/src/vite/vite-preview.ts (content)
⚔️ pnpm-lock.yaml (content)
⚔️ pnpm-workspace.yaml (content)
⚔️ scripts/ci-validate-in-docker.ps1 (content)
⚔️ scripts/ci-validate-in-docker.sh (content)
⚔️ vitest.config.ts (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the primary change: adding DrawIO export functionality plus a cleanup pass, which aligns with the comprehensive changeset.
Description check ✅ Passed The PR description is comprehensive and well-organized, covering features, cleanup work, and specific code changes. While a formal checklist is absent, the content fulfills all required information needs.

✏️ 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
  • Commit unit tests in branch feat/drawio-export

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

@sraphaz sraphaz merged commit fc6015b into main Feb 14, 2026
29 checks passed
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.

1 participant