Skip to content

Make diagram IDs from the file path, not the folder - #10

Merged
TheoBen880 merged 1 commit into
mainfrom
fix/diagram-id-from-path
Oct 20, 2026
Merged

TheoBen880 merged 1 commit into
mainfrom
fix/diagram-id-from-path

Conversation

@TheoBen880

Copy link
Copy Markdown
Collaborator

Fixes UIG-198. npx uigraph refused a correct .uigraph.yaml when two diagram files were in the same folder. uigraph-cli sync accepted the same file.

Before and after

Before: The viewer made each diagram ID from the name of the folder that holds the diagram file. Two diagrams in one folder got the same ID, and the viewer stopped:

✖ The UIGraph artifacts are invalid:
  • .uigraph.yaml: architectureDiagrams[Order Containers]: another diagram already uses the folder "diagram"

After: The viewer makes each diagram ID from the full file path in .uigraph.yaml. Two diagrams in one folder get different IDs, and the viewer opens both.

Disadvantages:

  • The ID of each diagram changes, so the viewer URL /diagram/<id> changes too. Old bookmarks to a diagram do not open.
  • Diagrams in one folder now load, but they share that folder. From the code (not tested): when a diagram has no contextPath, its first save in the viewer writes <folder>/context.json. Thus a save of the second diagram writes over the layout of the first. When the user deletes one diagram, the viewer also deletes the images of the other diagrams in <folder>/images.

Risk

The change touches the ID of all architecture diagrams in the viewer. No .uigraph.yaml file keeps a diagram ID, because links to a diagram use its name. Thus no saved data changes. A revert fully undoes the change.

Evidence

A test repository has two diagrams, diagram/order-flow.mmd and diagram/order-containers.mmd:

Errors Diagram IDs
Before another diagram already uses the folder "diagram" diagram
After none diagram-order-flow-mmd, diagram-order-containers-mmd

uigraph-cli sync --dry-run syncs the two diagrams.

63 tests pass. Two tests in src/bin.test.ts fail because they time out. These tests run the old build in dist/bin.mjs, which does not contain this change. I did not build the package or open the diagrams in a browser.

What changed

Bug fixes:

  • The viewer accepts two or more diagrams in one folder.
  • A diagram that the viewer makes gets an ID in the same format.

Breaking changes:

  • Viewer URLs of diagrams change. Users must open each diagram again from the diagram list.

Checklist

  • Make the diagram ID from the file path
  • Change the tests that expect the old IDs
  • Test a repository that has two diagrams in one folder
  • Run src/bin.test.ts on a new build
  • Open two diagrams from one folder in the viewer in a browser

Other options

  • Make the ID from the diagram name: a rename in the viewer would change the ID and break the open page.

@linear-code

linear-code Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
UIG-198 Fix incorrect artifact validation failure in `npx uigraph`

Running npx uigraph (UIGraph v1.0.4) rejects artifacts as invalid, although the same artifacts sync successfully with uigraph-cli sync.

The error is .uigraph.yaml: architectureDiagrams[Agent Trust Containers]: another diagram already uses the folder "diagram".

Artifact validation error

Diagrams available after syncing

Review in Linear

@TheoBen880
TheoBen880 merged commit 92c6d4f into main Oct 20, 2026
1 check 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