Repository navigation
Add Mermaid resource graph export to the dashboard and CLI - #20746
Conversation
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 717ed183-6459-4f56-bcd9-320a67093908
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 20746Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 20746" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The export can produce an empty graph when clicked before asynchronous graph initialization completes.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Adds Mermaid export for the dashboard resource graph, reflecting current visibility and filters.
Changes:
- Generates deterministic, escaped Mermaid flowcharts.
- Adds an export dialog with copy and download actions.
- Adds localization, documentation, and test coverage.
| File | Description |
|---|---|
tests/Aspire.Dashboard.Tests/Model/Snapshots/ResourceGraphMermaidExporterTests.Export_ResourcesAndConnections.verified.mmd |
Snapshots resources and edges. |
tests/Aspire.Dashboard.Tests/Model/Snapshots/ResourceGraphMermaidExporterTests.Export_EscapesLabelsAndUsesSafeIdentifiers.verified.mmd |
Snapshots escaping and identifiers. |
tests/Aspire.Dashboard.Tests/Model/Snapshots/ResourceGraphMermaidExporterTests.Export_Empty.verified.mmd |
Snapshots an empty graph. |
tests/Aspire.Dashboard.Tests/Model/ResourceGraphMermaidExporterTests.cs |
Tests exporter behavior. |
tests/Aspire.Dashboard.Tests/Aspire.Dashboard.Tests.csproj |
Adds Verify snapshot support. |
tests/Aspire.Dashboard.Components.Tests/Shared/ResourceSetupHelpers.cs |
Supports injected dialog services. |
tests/Aspire.Dashboard.Components.Tests/Pages/ResourcesTests.cs |
Tests filtered graph export. |
tests/Aspire.Dashboard.Components.Tests/Controls/TextVisualizerDialogTests.cs |
Tests copy and download behavior. |
src/Aspire.Dashboard/Resources/xlf/Resources.zh-Hant.xlf |
Adds localized resource entry. |
src/Aspire.Dashboard/Resources/xlf/Resources.zh-Hans.xlf |
Adds localized resource entry. |
src/Aspire.Dashboard/Resources/xlf/Resources.tr.xlf |
Adds localized resource entry. |
src/Aspire.Dashboard/Resources/xlf/Resources.ru.xlf |
Adds localized resource entry. |
src/Aspire.Dashboard/Resources/xlf/Resources.pt-BR.xlf |
Adds localized resource entry. |
src/Aspire.Dashboard/Resources/xlf/Resources.pl.xlf |
Adds localized resource entry. |
src/Aspire.Dashboard/Resources/xlf/Resources.ko.xlf |
Adds localized resource entry. |
src/Aspire.Dashboard/Resources/xlf/Resources.ja.xlf |
Adds localized resource entry. |
src/Aspire.Dashboard/Resources/xlf/Resources.it.xlf |
Adds localized resource entry. |
src/Aspire.Dashboard/Resources/xlf/Resources.fr.xlf |
Adds localized resource entry. |
src/Aspire.Dashboard/Resources/xlf/Resources.es.xlf |
Adds localized resource entry. |
src/Aspire.Dashboard/Resources/xlf/Resources.de.xlf |
Adds localized resource entry. |
src/Aspire.Dashboard/Resources/xlf/Resources.cs.xlf |
Adds localized resource entry. |
src/Aspire.Dashboard/Resources/Resources.resx |
Defines export button text. |
src/Aspire.Dashboard/Resources/Resources.Designer.cs |
Exposes the localized string. |
src/Aspire.Dashboard/README.md |
Documents Mermaid export. |
src/Aspire.Dashboard/Model/ResourceGraph/ResourceGraphMermaidExporter.cs |
Implements Mermaid generation. |
src/Aspire.Dashboard/Components/Pages/Resources.razor.cs |
Opens the export dialog. |
src/Aspire.Dashboard/Components/Pages/Resources.razor |
Adds the export control. |
Files not reviewed (1)
- src/Aspire.Dashboard/Resources/Resources.Designer.cs: Generated file
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 717ed183-6459-4f56-bcd9-320a67093908
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Co-authored-by: Copilot App <[email protected]> Co-authored-by: Copilot <[email protected]> Copilot-Session: 717ed183-6459-4f56-bcd9-320a67093908
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The export logic, filtering behavior, escaping, accessibility, localization, and dialog actions are covered without unresolved issues.
Review effort: Balanced
Findings: None
Resolved since last review (2)
Files not reviewed (1)
- src/Aspire.Dashboard/Resources/Resources.Designer.cs: Generated file
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 717ed183-6459-4f56-bcd9-320a67093908
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Replica selection loses unique names, and case-variant self-references produce unintended self-loops.
Review effort: Balanced
Findings: 1
Open (1)
Files not reviewed (2)
- src/Aspire.Cli/Resources/DescribeCommandStrings.Designer.cs: Generated file
- src/Aspire.Dashboard/Resources/Resources.Designer.cs: Generated file
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
PR Testing ReportPR Information
Artifact Version Verification
testDir="$(mktemp -d -t aspire-pr20746-XXXXXX)"
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh |
bash -s -- 20746 --install-path "$testDir" --skip-path --skip-extension
cliPath="$testDir/dogfood/pr-20746/bin/aspire"
hivePath="$testDir/hives/pr-20746/packages"
"$cliPath" --versionResult: Installation and version verification passed. Final CI ResultsAll current-head checks finished: 249 passing, 6 skipped, 0 pending, 0 failing. Earlier failures in CLI/Ubuntu and Hosting.JavaScript/Windows subsequently passed on rerun; the final result above is not the earlier failed attempt. Changes AnalyzedCLI command/output routing, shared Mermaid serialization, dashboard graph mapping/export dialog, localization, documentation, and focused tests. No hosting integration, extension, or CI infrastructure behavior was changed by this PR. Test Scenarios Executed
Fresh applications and readiness"$cliPath" new aspire-starter --name MermaidSmoke --output "$testDir/MermaidSmoke" \
--source "$hivePath" --version 17.0.0-pr.20746.g347b8bb9 \
--test-framework None --use-redis-cache false --localhost-tld false \
--suppress-agent-init --non-interactive
"$cliPath" start --non-interactive \
--apphost "$testDir/MermaidSmoke/MermaidSmoke.AppHost/MermaidSmoke.AppHost.csproj" --format JsonCreation passed; startup returned exit 2 with the CS0234 errors described above. Rather than modifying the generated Blazor project to hide this failure, testing continued with a fresh empty application: "$cliPath" new aspire-empty --name MermaidEmpty --output "$testDir/MermaidEmpty" \
--source "$hivePath" --version 17.0.0-pr.20746.g347b8bb9 \
--localhost-tld false --suppress-agent-init --non-interactive
apphost="$testDir/MermaidEmpty/apphost.cs"
"$cliPath" start --non-interactive --apphost "$apphost" --format JsonBoth passed. The generated empty template uses The empty application was stopped, then its temporary AppHost was extended with two "$cliPath" start --non-interactive --apphost "$apphost" --format Json
"$cliPath" wait frontend --status up --timeout 60 --apphost "$apphost" --non-interactiveResult: Both passed. Compiled CLI export commands"$cliPath" resources --apphost "$apphost" --format mermaid >> "$evidence/pr20746-topology.mmd"
"$cliPath" describe --apphost "$apphost" --format=MERMAID > "$evidence/pr20746-alias.mmd"
cmp "$evidence/pr20746-topology.mmd" "$evidence/pr20746-alias.mmd"
"$cliPath" resources frontend --apphost "$apphost" --format mermaid > "$evidence/pr20746-filter.mmd"
"$cliPath" resources --apphost "$apphost" --format mermaid --include-hidden > "$evidence/pr20746-hidden.mmd"
"$cliPath" resources --apphost "$apphost" --format mermaid >> "$evidence/pr20746-append.mmd"
"$cliPath" resources --apphost "$apphost" --format mermaid >> "$evidence/pr20746-append.mmd"Result: Passed, with complete-content assertions. Human-readable stderr was captured separately. flowchart LR
resource0["backend"]
resource1["frontend"]
resource1 --> resource0
Browser and parser validationAn isolated Playwright/Chromium harness tested the actual dashboard launched by the PR bundle, including clipboard read-back and a real browser download. Mermaid was parsed in Chromium using the installed Mermaid module served only on localhost. node "$evidence/pr20746-browser.cjs"Result: Passed: source, clipboard, filename/content, filtered export, and all five parser inputs. Initial harness attempts entered filter text while the previous dialog was closing and triggered dashboard navigation shortcuts. The filter assertion was rerun successfully in a fresh page with explicitly focused search input; those initial harness attempts are not counted as feature passes. Negative commands and cleanup"$cliPath" resources --apphost "$apphost" --format mermaid --follow
"$cliPath" resources nonexistent --apphost "$apphost" --format mermaid
"$cliPath" stop --non-interactive --apphost "$apphost"
"$cliPath" resources --apphost "$apphost" --format mermaidResults: Expected exits 1, 7, 0, 0 respectively. Both invalid invocations and the no-running-AppHost invocation emitted zero stdout bytes. Only the test-created AppHost was stopped. Supporting Source Validation — Historical, Not Artifact ScenariosPreviously completed on this same head: 165 CLI command/base/root tests, 3 dashboard serializer tests, and 29 graph/text-dialog component tests passed. Localization generation passed. These are supporting source-test results, not substitutes for the fresh artifact scenarios above. EvidenceReport, browser harness, logs, output files, and inspected screenshots are saved in this session's artifact directory:
Key files: Fresh screenshots: Limitations and Recommendations
Overall ResultMermaid CLI/dashboard artifact scenarios passed on the current PR head. CI is green. A separate starter smoke-test build failure remains unresolved, so this is not an unqualified end-to-end verification of every PR smoke scenario. |
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 717ed183-6459-4f56-bcd9-320a67093908
|
Fixed the case-variant self-reference issue noted in the review summary: Mermaid self-reference exclusion now uses the same case-insensitive resource-name comparison as relationship resolution. Added mixed-case Reference and WaitFor inputs to the topology regression tests; all 44 DescribeCommand tests pass with the existing snapshots unchanged. The single-replica label finding remains deferred by user decision; its thread is still open. |
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 717ed183-6459-4f56-bcd9-320a67093908
Tests selector15 / 98 PR test projects · 5 PR jobs, from 58 changed files. Selected PR test projects (15 / 98)
Selected PR jobs (5)
How these were chosen — grouped by what changed
🔧 📦 affected project 📦 affected project 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 Job reasons
Selection computed for commit |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation is coherent across dashboard and CLI surfaces with focused coverage for filtering, escaping, replicas, output routing, and interaction behavior.
Review effort: Balanced
Findings: None
Resolved since last review (1)
Files not reviewed (2)
- src/Aspire.Cli/Resources/DescribeCommandStrings.Designer.cs: Generated file
- src/Aspire.Dashboard/Resources/Resources.Designer.cs: Generated file
Documents microsoft/aspire#20746, which adds an Export as Mermaid action to the dashboard resource graph and a --format mermaid option to aspire describe / aspire resources. Co-authored-by: Copilot <[email protected]>
|
Pull request created: #1829
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#1829 targeting Documented the new Mermaid resource-graph export added by #20746. Triggered signals and evidence covered:
Changes made:
Note This draft PR needs human review before merging. |


Description
Resource graphs are useful for documenting and sharing an application's topology, but currently cannot be exported from the dashboard or CLI. This adds Export as Mermaid to the graph controls, opening a large dialog with the generated source, Copy to clipboard, and Download as
resources.mmd. It also addsaspire resources --format mermaid(andaspire describe --format mermaid) for direct file redirection.The dashboard export reflects the graph's current filters and hidden-resource visibility. The CLI exports the selected AppHost's resource snapshot, respecting resource-name selection and
--include-hidden. Both use the same serializer for deterministic ordering, generated node identifiers, and escaped labels, and preserve directed resource references and replica names. The dashboard reuses the existing text visualizer dialog in plaintext mode. CLI progress, errors, and informational messages stay on stderr so stdout contains only Mermaid source.This intentionally includes source, copy, and download only; a rendered Mermaid preview is deferred, with no new browser dependency. Mermaid CLI output is snapshot-only and rejects
--follow.User-facing usage
Open Resources → Graph, apply any desired filters, and select the download icon in the lower-right graph controls. Copy the source into a Mermaid-enabled document, or download
resources.mmdfor use in a Mermaid editor.From the CLI:
Each invocation exports one diagram. Appending repeated invocations with
>>produces multiple diagrams, not a merged diagram.The compiled command's help now includes:
Screenshots / Recordings
Graph controls with the new export action:
Export dialog showing the generated source and copy/download actions:
Screenshots use synthetic integration-test resources.
Validation
./restore.sh— passed.MSBUILDTERMINALLOGGER=false dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class '*.DescribeCommandTests' --filter-class '*.BaseCommandTests' --filter-class '*.RootCommandTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'— passed, 165 tests, including topology/escaping snapshots, filtering, replicas, format parsing, stderr routing, and first-run banner suppression.MSBUILDTERMINALLOGGER=false dotnet test --project tests/Aspire.Dashboard.Tests/Aspire.Dashboard.Tests.csproj --no-launch-profile -- --filter-class '*.ResourceGraphMermaidExporterTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'— passed, 3 tests; existing exporter snapshots remain unchanged after sharing the serializer.MSBUILDTERMINALLOGGER=false dotnet test --project tests/Aspire.Dashboard.Components.Tests/Aspire.Dashboard.Components.Tests.csproj --no-launch-profile -- --filter-method '*.ResourceGraph*' --filter-method '*.Render_TextVisualizer*' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'— passed, 29 tests.MSBUILDTERMINALLOGGER=false dotnet build src/Aspire.Cli/Aspire.Cli.csproj /t:UpdateXlf --nologo— passed; regenerated localization files../.dotnet/dotnet artifacts/bin/Aspire.Cli/Debug/net11.0/aspire.dll resources --help— passed; confirms the new format in compiled command help.git diff --check— passed.Security considerations
Resource display names are user-controlled. The shared exporter generates its own node identifiers and escapes label characters instead of interpolating raw names into Mermaid syntax. It exports only resource display names and references, not endpoint URLs, configuration values, or environment variables. Users should review resource names before sharing exported diagrams. No Mermaid source is executed or rendered in the dashboard or CLI.
Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?