Skip to content

fix(gitGraph): correct BT orientation arc sweep flags#7424

Merged
knsv merged 4 commits intodevelopfrom
bug/6593_bot-fix-bt-curves
Feb 28, 2026
Merged

fix(gitGraph): correct BT orientation arc sweep flags#7424
knsv merged 4 commits intodevelopfrom
bug/6593_bot-fix-bt-curves

Conversation

@knsv
Copy link
Copy Markdown
Collaborator

@knsv knsv commented Feb 27, 2026

Summary

Fixes the BT (bottom-to-top) orientation arrow curves in gitGraph diagrams. One specific code path in drawArrow() had two errors causing curves to bend incorrectly when a branch to the right of main draws a non-merge arrow back leftward.

Resolves #6593

What was wrong

In gitGraphRenderer.ts, the non-rerouting BT p1.x > p2.x non-merge path (line ~748) had two bugs:

  1. p2.x - radius should be p2.x + radius — the horizontal line segment extended past the target in the wrong direction
  2. arc (sweep=0) should be arc2 (sweep=1) — the SVG arc swept the wrong way

The BT orientation is derived from TB by flipping Y-direction offsets and swapping arc sweep flags. The TB p1.x > p2.x non-merge path uses p2.x + radius and arc, so BT should use p2.x + radius and arc2. The original code incorrectly had p2.x - radius and arc.

Changes

packages/mermaid/src/diagrams/git/gitGraphRenderer.ts — 1 line changed:

- lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${
+ lineDef = `M ${p1.x} ${p1.y} L ${p2.x + radius} ${p1.y} ${arc2} ${p2.x} ${

cypress/integration/rendering/gitGraph.spec.js — 4 new E2E regression tests:

Test Scenario
76 Branch ordering with merge from right branch (BT)
77 Three branches with multiple merges (BT)
78 Cherry-pick (BT) — original #6593 reproduction
79 Two cherry-picks (BT)

Test plan

  • Existing unit tests pass (106 passed, 4 skipped)
  • Lint passes
  • Visually verified all BT diagrams render correct curves via dev server
  • E2E snapshot baselines need to be generated for the 4 new tests

knsv and others added 2 commits February 27, 2026 16:49
These files (CLAUDE.md, AGENTS.md, assistant/, .claude/skills/,
package-level CLAUDE.md files) are synced from the mermaid-ops
control plane via /sync and should not be committed to this repo.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Swap SVG arc sweep-flag values in the BT (bottom-to-top) orientation
branches of drawArrow() so curves bend in the correct direction.

Fixes both rerouting and non-rerouting code paths for merge and
non-merge arrows. Also fixes an incorrect x-coordinate in the
non-rerouting BT p1.x>p2.x non-merge case.

Resolves #6593

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 27, 2026

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 9dcbf0e
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/69a29ccd99d5da000838d961
😎 Deploy Preview https://deploy-preview-7424--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 27, 2026

🦋 Changeset detected

Latest commit: 9dcbf0e

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

This PR includes changesets to release 1 package
Name Type
mermaid 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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 27, 2026

Open in StackBlitz

@mermaid-js/examples

npm i https://pkg.pr.new/@mermaid-js/examples@7424

mermaid

npm i https://pkg.pr.new/mermaid@7424

@mermaid-js/layout-elk

npm i https://pkg.pr.new/@mermaid-js/layout-elk@7424

@mermaid-js/layout-tidy-tree

npm i https://pkg.pr.new/@mermaid-js/layout-tidy-tree@7424

@mermaid-js/mermaid-zenuml

npm i https://pkg.pr.new/@mermaid-js/mermaid-zenuml@7424

@mermaid-js/parser

npm i https://pkg.pr.new/@mermaid-js/parser@7424

@mermaid-js/tiny

npm i https://pkg.pr.new/@mermaid-js/tiny@7424

commit: 9c85b43

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 3.55%. Comparing base (33c7c72) to head (9dcbf0e).
⚠️ Report is 5 commits behind head on develop.

Files with missing lines Patch % Lines
...kages/mermaid/src/diagrams/git/gitGraphRenderer.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #7424   +/-   ##
=======================================
  Coverage     3.55%   3.55%           
=======================================
  Files          489     489           
  Lines        48729   48729           
  Branches       765     765           
=======================================
  Hits          1734    1734           
  Misses       46995   46995           
Flag Coverage Δ
unit 3.55% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...kages/mermaid/src/diagrams/git/gitGraphRenderer.ts 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@argos-ci
Copy link
Copy Markdown

argos-ci Bot commented Feb 27, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) 👍 Changes approved 4 added Feb 28, 2026, 7:54 AM

knsv and others added 2 commits February 27, 2026 17:37
Revert 5 of 6 arc swaps from previous commit — only the
non-rerouting BT p1.x > p2.x non-merge case was actually wrong.
The other 5 cases were correct in the original code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add 4 new visual snapshot tests in the BT section that exercise
the fixed arc path: branch ordering with merge from right branch,
three-branch merge, cherry-pick, and double cherry-pick — all in
BT orientation.

Resolves #7423

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@knsv knsv marked this pull request as ready for review February 28, 2026 07:49
Copy link
Copy Markdown
Collaborator Author

@knsv knsv left a comment

Choose a reason for hiding this comment

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

LGTM!

@knsv knsv merged commit 7cdfe75 into develop Feb 28, 2026
28 checks passed
@knsv knsv deleted the bug/6593_bot-fix-bt-curves branch February 28, 2026 09:23
This was referenced Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug / Error Something isn't working or is incorrect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gitGraph BT: wrong curve when commit line goes left then up

1 participant