Skip to content

fix(atlas): draw one graph arrow per distinct relationship - #2049

Merged
nathanschmid08 merged 1 commit into
Avenx-JS:mainfrom
noahkhomer18:fix/2045-atlas-duplicate-edges
Nov 27, 2026
Merged

nathanschmid08 merged 1 commit into
Avenx-JS:mainfrom
noahkhomer18:fix/2045-atlas-duplicate-edges

Conversation

@noahkhomer18

Copy link
Copy Markdown
Contributor

What this changes

renderAtlasGraph now draws one arrow per distinct (from, to, kind). The model keeps one edge per source location, which is right for the text output and for loc, but the graph drew every one of them, so a page that renders the same component twice got two identical renders arrows and two linkStyle lines. Both avenx atlas --graph and avenx inspect --graph go through this function, and so does the DOT output.

When one copy of a relationship is certain and another only possible, the certain one decides the arrow, so a proven relationship is not drawn dashed just because a weaker copy was found first. Different kinds between the same pair (renders and imports, say) still get an arrow each.

Related issue

Closes #2045

How was this verified?

The real CLI, before and after. I copied test/fixtures/atlas-app, made cart.page.js render <CartList /> twice, and ran avenx atlas --graph --focus page:Cart. diff main.txt branch.txt:

28,29d27
<   n4 -->|"renders"| n2
<   linkStyle 6 stroke:#db2777
31c29
<   linkStyle 7 stroke:#2563eb
---
>   linkStyle 6 stroke:#2563eb
33c31
<   linkStyle 8 stroke:#2563eb
---
>   linkStyle 7 stroke:#2563eb

The duplicate arrow is gone and the linkStyle indexes stay contiguous. Nothing else in the output changed.

New test, test/unit/atlasGraphDuplicateEdges.test.js: two renders edges from different lines give one arrow, an imports edge between the same pair keeps its own, linkStyle indexes match the arrows, the DOT output has the same edge count, and a possible copy followed by a certain one gives one solid arrow. With graph.js reverted to main it fails with repeated component usage draws one renders arrow.

$ npm run test:unit
Total: 318 | Passed: 318 | Failed: 0
$ npm run test:integration
Total: 25 | Passed: 25 | Failed: 0
$ npm run test:system
Total: 89 | Passed: 89 | Failed: 0
$ npm run lint      # exit 0

npx prettier --check flags one line in graph.js (the atlasKindAliases map, line 14), which it flags on main too, so I left it alone. The block I wrote and the new test are formatted.

Checklist

  • npm test passes (unit, integration and system tiers, run one by one above)
  • npm run lint passes
  • Tests added or updated where appropriate
  • Documentation updated where user-facing behavior changed (no doc shows the duplicate arrows)
  • If a diagnostic code was added, the steps in CONTRIBUTING.md were followed (no diagnostic added)

The model keeps one edge per source location, so a page that renders the same component twice gave atlas --graph and inspect --graph two identical arrows, each with its own linkStyle index.

Collapse edges by (from, to, kind) before rendering, in both Mermaid and DOT output. When one copy is certain and another only possible, the certain one decides the arrow style, so a proven relationship is not drawn dashed.

Closes Avenx-JS#2045

Signed-off-by: Noah Khomer <108771853+noahkhomer18@users.noreply.github.com>
@nathanschmid08 nathanschmid08 self-assigned this Nov 27, 2026
@nathanschmid08
nathanschmid08 self-requested a review November 27, 2026 13:24
@nathanschmid08

Copy link
Copy Markdown
Member

@all-contributors please add @noahkhomer18 for code

@allcontributors

Copy link
Copy Markdown
Contributor

@nathanschmid08

I've put up a pull request to add @noahkhomer18! 🎉

@nathanschmid08 nathanschmid08 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good 👍

@nathanschmid08

Copy link
Copy Markdown
Member

Hi @noahkhomer18 , Thanks for the PR. I appreciate it very much. Nice to see you at Avenx 😉

I just finished up my review and it looks really good, therefore I will merge your PR now.

Thanks again and enjoy the weekend!

@nathanschmid08
nathanschmid08 merged commit b06e8b0 into Avenx-JS:main Nov 27, 2026
9 of 10 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.

Bug: the Atlas graph draws a duplicate arrow for every repeated component usage

2 participants