Consistent resource colors, resource colors match dashboard#14832
Consistent resource colors, resource colors match dashboard#14832JamesNK merged 5 commits intorelease/13.2from
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14832Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14832" |
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where resource colors could change depending on encounter order (e.g., when filtering resources). The fix pre-resolves all known resource names sorted alphabetically at startup so that color index assignments are deterministic, regardless of which resources are displayed or the order they are returned.
Changes:
- Moves
ColorGeneratorto a shared file (namespaceAspire) compiled into both the dashboard and CLI, and adds aResolveAll(IEnumerable<string> keys)method that pre-sorts and resolves colors for all known resource names - Updates
ResourceColorMapin the CLI to useColorGeneratorand maps CSS accent variable names to dark-theme hex colors matching the dashboard palette for visual consistency - Updates
DashboardClient(dashboard) andLogsCommand/DescribeCommand(CLI) to callResolveAllat startup with all resource display names; also refactorsDescribeCommandto fetch snapshots and dashboard URL in parallel and pass them to both paths
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/Shared/ColorGenerator.cs |
Namespace changed from Aspire.Dashboard.Otlp.Model to Aspire; exposed s_variableNames and GetColorIndex as internal; added public ResolveAll method |
src/Aspire.Dashboard/ServiceClient/DashboardClient.cs |
Calls ColorGenerator.Instance.ResolveAll() inside the resource-watch lock after each batch of changes |
src/Aspire.Dashboard/Aspire.Dashboard.csproj |
Adds shared ColorGenerator.cs to compile items |
src/Aspire.Dashboard/Components/_Imports.razor |
Adds @using Aspire to make ColorGenerator accessible in Razor components |
src/Aspire.Dashboard/Model/ResourceGraph/ResourceGraphMapper.cs |
Removes now-unneeded using Aspire.Dashboard.Otlp.Model |
src/Aspire.Dashboard/Model/Assistant/Markdown/ResourceInlineRenderer.cs |
Removes now-unneeded using Aspire.Dashboard.Otlp.Model |
src/Aspire.Cli/Utils/ResourceColorMap.cs |
Replaces static Spectre Color[] with a ColorGenerator-backed palette; maps CSS variables to dashboard dark-theme hex values |
src/Aspire.Cli/Aspire.Cli.csproj |
Adds shared ColorGenerator.cs to compile items |
src/Aspire.Cli/Commands/LogsCommand.cs |
Calls _resourceColorMap.ResolveAll() after fetching the initial snapshot list |
src/Aspire.Cli/Commands/DescribeCommand.cs |
Fetches snapshots and dashboard URLs in parallel; calls ResolveAll; refactors ExecuteSnapshotAsync to sync ExecuteSnapshot and ExecuteWatchAsync to accept pre-fetched data |
tests/Aspire.Cli.Tests/Utils/ResourceColorMapTests.cs |
New test file covering key matching, determinism, and uniqueness of color assignment |
🎬 CLI E2E Test RecordingsThe following terminal recordings are available for commit
📹 Recordings uploaded automatically from CI run #22601324541 |
d0f4094 to
6858846
Compare
mitchdenny
left a comment
There was a problem hiding this comment.
Clean fix — ResolveAll() ensures deterministic color assignment regardless of encounter order. Good that CLI and dashboard now share the same palette via ColorGenerator. Tests verify determinism nicely.
Description
Resource color assignment is based on the order resource color is resolved. That can change based on filtered data.
PR changes:
Fixes #14292
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: