Skip to content

Keep dashboard resource ordering stable and protect saved customizations - #22471

Merged
James Newton-King (JamesNK) merged 18 commits into
mainfrom
dashboard-relative-resource-order
Nov 24, 2026
Merged

James Newton-King (JamesNK) merged 18 commits into
mainfrom
dashboard-relative-resource-order

Conversation

@JamesNK

@JamesNK James Newton-King (JamesNK) commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Description

The dashboard resource pane could show a different order depending on when it was opened. Resources discovered after the first snapshot were appended, and the browser saved that order even if the user had never moved anything.

  • Late resources and new groups now enter their default sort order. The dashboard saves only explicit moves, separately for resources and for groups within each grouping mode. It reapplies each move after the previous neighbor at the drop position, or before the next neighbor if the previous one is unavailable. Resources still stay under their parent.
  • Resource moves, group moves, user-added resource tags, and metric pins now use protected browser local storage. AppHost-declared tags are unchanged.

User-facing usage

With Grouping = None, if frontend and worker are already visible and proxy (a project) and redis (a container) are discovered later, the pane shows redis, frontend, proxy, worker rather than appending the new rows. You can still drag a resource to reorder it among its siblings without freezing the rest of the list.

Previously saved full-list orders, plaintext tags, and plaintext pins are not migrated. The dashboard starts with default ordering and no saved personal tags or pins. The next tag or pin edit replaces the corresponding plaintext value with a protected value. If the dashboard can no longer decrypt a saved value, that setting also returns to its default.

TODO (if users report hitting these limits): Add a way to clear obsolete metric pins and inaccessible personal tag assignments from the dashboard. Pins without matching telemetry and assignments for removed resources or tags now declared by the AppHost still count toward their respective limits. The dashboard currently cannot clear those entries.

Screenshots / Recordings

This PR includes UI changes. Please add screenshots or screen recordings so reviewers can evaluate the visual changes without running locally.

  • For before/after comparisons, place them side-by-side or label them clearly.
  • For interactive changes (animations, transitions, new flows), prefer a short screen recording (GIF or video).
  • If you cannot capture visuals now, note what scenario to test and mark this section as TODO.

TODO: Record the resource pane during discovery with Grouping = None to show late rows moving into their default positions. Then reorder a resource and reload to show that the move persists.

Security considerations

The dashboard uses its existing ASP.NET Core Data Protection keys to protect these values. It does not fall back to plaintext or create new plaintext backups. Existing plaintext entries and backups are not proactively removed. Protection applies to values, not the browser storage key names.

Validation

  • 43 model tests passed on the final implementation, covering both storage modes, resetting legacy plaintext, and replaying moves when anchors disappear.
  • 230 component tests passed before the final helper change. The component tests were not rerun after restoring the unprotected option; all production callers still explicitly select protected storage.
Test commands

Final model run (43 passed):

$testBin = Join-Path (Get-Location).Path 'artifacts\storage-mode-test-bin\'
.\dotnet.cmd test --project tests\Aspire.Dashboard.Tests\Aspire.Dashboard.Tests.csproj --no-restore --no-launch-profile "-p:ArtifactsBinDir=$testBin" -- --filter-class '*.LocalStorageSettingTests' --filter-class '*.ResourceOrderStoreTests' --filter-class '*.ResourceTagStoreTests' --filter-class '*.MetricPinStoreTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'

Earlier component run (230 passed):

$testBin = Join-Path (Get-Location).Path 'artifacts\move-protection-test-bin\'
.\dotnet.cmd test --project tests\Aspire.Dashboard.Components.Tests\Aspire.Dashboard.Components.Tests.csproj --no-restore --no-launch-profile "-p:ArtifactsBinDir=$testBin" -- --filter-class '*.ResourcesLayoutTests' --filter-class '*.MetricsTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22471

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22471"

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the move-based dashboard ordering changes.

No open issues 🎉

What changed in this PR

This PR makes dashboard resource ordering independent of discovery timing by replaying explicit user moves over the default sort order, rather than saving full-list positions.

Changes:

  • Places late resources and groups in their default sort order while preserving resource hierarchy.
  • Saves resource moves and per-grouping-mode group moves separately in browser local storage, using neighboring items as anchors. Previous full-list orders are not migrated.
  • Updates model tests, component tests, and documentation for the new ordering behavior.
File Description
tests/​Aspire.Dashboard.Tests/​Model/​ResourceOrderStoreTests.cs Tests move persistence, neighbor fallback, cross-tab updates, and storage recovery.
tests/​Aspire.Dashboard.Components.Tests/​Layout/​ResourcesLayoutTests.cs Verifies late-item sorting, hierarchy preservation, and reorder restrictions.
src/​Aspire.Dashboard/​Utils/​BrowserStorageKeys.cs Defines separate storage keys for resource and group moves.
src/​Aspire.Dashboard/​Serialization/​DashboardJsonSerializerContext.cs Registers move collections for JSON serialization.
src/​Aspire.Dashboard/​README.md Documents default sorting and browser-local move persistence.
src/​Aspire.Dashboard/​Model/​ResourceOrderStore.cs Replaces saved positions with relative moves replayed over default ordering.
src/​Aspire.Dashboard/​Components/​Layout/​ResourcesLayout.razor.cs Integrates move-based ordering into resource and group rendering.
docs/​specs/​dashboard-persistence.md Updates the persistence specification to describe relative ordering.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot November 20, 2026 06:57
@JamesNK James Newton-King (JamesNK) changed the title Preserve dashboard resource order with relative moves Keep dashboard resource ordering stable and protect saved customizations Nov 20, 2026
@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Repeated reorders grow saved history without bound, eventually exceeding SignalR’s 32 KiB receive limit and disconnecting the dashboard circuit.

2 open issues

Review effort: Balanced

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The 50-move cap can still produce protected settings exceeding SignalR’s 32 KiB receive limit with maximum-length Unicode tags, causing local-storage reads to disconnect the dashboard even after reload.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

High severity Cap protected group settings to SignalR’s payload limit

src/​Aspire.Dashboard/​Model/​ResourceOrderStore.cs:209

The 50-move cap still allows a protected group setting to exceed SignalR's 32 KiB default receive limit (upstream default-branch source): 50 moves with maximum-length CJK tag keys and anchors exceed that limit even without JSON escaping or protection overhead. Saving can succeed, but the next local-storage read sends the oversized value back over SignalR and can disconnect the dashboard, including after reload. Enforce a serialized/protected size budget or split the payload, and extend the payload-size regression test to maximum-length Unicode tags.

2 resolved since last review

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed because entry-count caps do not bound protected payload size, allowing long-name or Unicode data to exceed SignalR’s message limit and disconnect the dashboard.

No open issues 🎉

Review effort: Balanced

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Two dashboard findings: one quota recovery issue and one missing user-facing quota error.

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed because the move and pin caps can still allow protected payloads exceeding SignalR’s 32 KiB limit, potentially disconnecting the dashboard on storage reads or reloads.

No open issues 🎉

Review effort: Balanced

@github-actions

This comment has been minimized.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…e save

Leave the displayed value unchanged on save failure and tell the user to retry. Keep cross-tab edits by reading storage before each save.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adopt defaults when the saved value is missing or invalid without rewriting storage. Preserve the current value when storage cannot be read.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Allow larger protected browser preferences to round-trip through the Blazor hub without changing the saved item caps.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Sibling-only key validation lets moves replay against the wrong resource when keys repeat across parents, reporting success without changing the displayed order.

2 open issues
2 resolved since last review
3 files not reviewed
  • src/Aspire.Dashboard/Resources/Layout.Designer.cs: Generated file
  • src/Aspire.Dashboard/Resources/Metrics.Designer.cs: Generated file
  • src/Aspire.Dashboard/Resources/Resources.Designer.cs: Generated file

Review effort: Max

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The sibling-only persistent-key ambiguity check can allow a move to report success while replay selects an old row under a different parent and leaves the replacement unmoved.

2 open issues
3 files not reviewed
  • src/Aspire.Dashboard/Resources/Layout.Designer.cs: Generated file
  • src/Aspire.Dashboard/Resources/Metrics.Designer.cs: Generated file
  • src/Aspire.Dashboard/Resources/Resources.Designer.cs: Generated file

Review effort: Max

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

14 / 101 PR test projects · 2 PR jobs, from 76 changed files.

Selected PR test projects (14 / 101)

Aspire.Dashboard.Components.Tests, Aspire.Dashboard.Tests, Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Tests, Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.DotnetTool.Tests, Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.Radius.Tests, Aspire.Hosting.Testing.Tests, Aspire.Hosting.Tests, Aspire.Playground.Tests, Aspire.Templates.Tests, Infrastructure.Tests

Selected PR jobs (2)

extension-e2e, native-dashboard-validation


How these were chosen — grouped by what changed

⚠️ 10 of the 14 selected test projects come from a single change — src/Aspire.Dashboard/Components/Controls/Chart/MetricPinButton.razor.

🔧 src/Aspire.Dashboard/Components/Controls/Chart/MetricPinButton.razor (changed source)
→ 10 via the project graph: Aspire.Hosting.Azure.Kubernetes.Tests (3 hops), Aspire.Hosting.Azure.Tests (2 hops), Aspire.Hosting.Blazor.Tests (2 hops), Aspire.Hosting.Dotnet.Tests (2 hops), Aspire.Hosting.DotnetTool.Tests (2 hops), Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.Radius.Tests (2 hops), Aspire.Hosting.Testing.Tests, Aspire.Hosting.Tests, Aspire.Playground.Tests (2 hops)

📦 affected project Aspire.Dashboard
→ 1 test: Aspire.Templates.Tests

🔧 src/Aspire.Dashboard/Resources/Layout.resx (changed source)
→ 1 directly: Infrastructure.Tests

🔧 src/Aspire.Dashboard/Resources/Metrics.resx (changed source)
→ 1 directly: Infrastructure.Tests

🔧 src/Aspire.Dashboard/Resources/Resources.resx (changed source)
→ 1 directly: Infrastructure.Tests

🧪 tests/Aspire.Dashboard.Components.Tests/Controls/ApplicationSummaryTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Components.Tests

🧪 tests/Aspire.Dashboard.Components.Tests/Controls/FluentDataGridLifecycleTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Components.Tests

🧪 tests/Aspire.Dashboard.Components.Tests/Controls/ResourceTagEditorTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Components.Tests

🧪 tests/Aspire.Dashboard.Components.Tests/Layout/ResourcesLayoutActivityTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Components.Tests

🧪 tests/Aspire.Dashboard.Components.Tests/Layout/ResourcesLayoutTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Components.Tests

🧪 tests/Aspire.Dashboard.Components.Tests/Layout/TerminalDockInitializationTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Components.Tests

🧪 tests/Aspire.Dashboard.Components.Tests/Pages/MetricsTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Components.Tests

🧪 tests/Aspire.Dashboard.Components.Tests/Pages/ResourcesTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Components.Tests

🧪 tests/Aspire.Dashboard.Components.Tests/Shared/DashboardPageTestContext.cs (changed test)
→ 1 directly: Aspire.Dashboard.Components.Tests

🧪 tests/Aspire.Dashboard.Components.Tests/Shared/TestLocalStorage.cs (changed test)
→ 1 directly: Aspire.Dashboard.Components.Tests

🧪 tests/Aspire.Dashboard.Tests/Integration/StartupTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Tests

🧪 tests/Aspire.Dashboard.Tests/Model/LocalStorageSettingTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Tests

🧪 tests/Aspire.Dashboard.Tests/Model/MetricPinStoreTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Tests

🧪 tests/Aspire.Dashboard.Tests/Model/ResourceOrderStoreTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Tests

🧪 tests/Aspire.Dashboard.Tests/Model/ResourceTagStoreTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Tests

🧪 tests/Aspire.Dashboard.Tests/Shared/InMemoryBrowserLocalStorage.cs (changed test)
→ 1 directly: Aspire.Dashboard.Tests

Job reasons

Job Triggered by
extension-e2e • src/Aspire.Dashboard/Components/Controls/Chart/MetricPinButton.razor, src/Aspire.Dashboard/Components/Controls/Chart/MetricPinButton.razor.cs, src/Aspire.Dashboard/Components/Controls/ResourceTagEditor.razor, src/Aspire.Dashboard/Components/Controls/ResourceTagEditor.razor.cs, src/Aspire.Dashboard/Components/Layout/ResourcesLayout.razor.cs, src/Aspire.Dashboard/DashboardWebApplication.cs, src/Aspire.Dashboard/Model/BrowserStorage/ILocalStorage.cs, src/Aspire.Dashboard/Model/BrowserStorage/LocalBrowserStorage.cs, src/Aspire.Dashboard/Model/BrowserStorage/LocalStorageSetting.cs, src/Aspire.Dashboard/Model/MetricPinStore.cs, src/Aspire.Dashboard/Model/ResourceOrderStore.cs, src/Aspire.Dashboard/Model/ResourceTagStore.cs, src/Aspire.Dashboard/Resources/Layout.Designer.cs, src/Aspire.Dashboard/Resources/Layout.resx, src/Aspire.Dashboard/Resources/Metrics.Designer.cs, src/Aspire.Dashboard/Resources/Metrics.resx, src/Aspire.Dashboard/Resources/Resources.Designer.cs, src/Aspire.Dashboard/Resources/Resources.resx, src/Aspire.Dashboard/Resources/xlf/Layout.cs.xlf, src/Aspire.Dashboard/Resources/xlf/Layout.de.xlf, src/Aspire.Dashboard/Resources/xlf/Layout.es.xlf, src/Aspire.Dashboard/Resources/xlf/Layout.fr.xlf, src/Aspire.Dashboard/Resources/xlf/Layout.it.xlf, src/Aspire.Dashboard/Resources/xlf/Layout.ja.xlf, src/Aspire.Dashboard/Resources/xlf/Layout.ko.xlf, src/Aspire.Dashboard/Resources/xlf/Layout.pl.xlf, src/Aspire.Dashboard/Resources/xlf/Layout.pt-BR.xlf, src/Aspire.Dashboard/Resources/xlf/Layout.ru.xlf, src/Aspire.Dashboard/Resources/xlf/Layout.tr.xlf, src/Aspire.Dashboard/Resources/xlf/Layout.zh-Hans.xlf, src/Aspire.Dashboard/Resources/xlf/Layout.zh-Hant.xlf, src/Aspire.Dashboard/Resources/xlf/Metrics.cs.xlf, src/Aspire.Dashboard/Resources/xlf/Metrics.de.xlf, src/Aspire.Dashboard/Resources/xlf/Metrics.es.xlf, src/Aspire.Dashboard/Resources/xlf/Metrics.fr.xlf, src/Aspire.Dashboard/Resources/xlf/Metrics.it.xlf, src/Aspire.Dashboard/Resources/xlf/Metrics.ja.xlf, src/Aspire.Dashboard/Resources/xlf/Metrics.ko.xlf, src/Aspire.Dashboard/Resources/xlf/Metrics.pl.xlf, src/Aspire.Dashboard/Resources/xlf/Metrics.pt-BR.xlf, src/Aspire.Dashboard/Resources/xlf/Metrics.ru.xlf, src/Aspire.Dashboard/Resources/xlf/Metrics.tr.xlf, src/Aspire.Dashboard/Resources/xlf/Metrics.zh-Hans.xlf, src/Aspire.Dashboard/Resources/xlf/Metrics.zh-Hant.xlf, src/Aspire.Dashboard/Resources/xlf/Resources.cs.xlf, src/Aspire.Dashboard/Resources/xlf/Resources.de.xlf, src/Aspire.Dashboard/Resources/xlf/Resources.es.xlf, src/Aspire.Dashboard/Resources/xlf/Resources.fr.xlf, src/Aspire.Dashboard/Resources/xlf/Resources.it.xlf, src/Aspire.Dashboard/Resources/xlf/Resources.ja.xlf, src/Aspire.Dashboard/Resources/xlf/Resources.ko.xlf, src/Aspire.Dashboard/Resources/xlf/Resources.pl.xlf, src/Aspire.Dashboard/Resources/xlf/Resources.pt-BR.xlf, src/Aspire.Dashboard/Resources/xlf/Resources.ru.xlf, src/Aspire.Dashboard/Resources/xlf/Resources.tr.xlf, src/Aspire.Dashboard/Resources/xlf/Resources.zh-Hans.xlf, src/Aspire.Dashboard/Resources/xlf/Resources.zh-Hant.xlf, src/Aspire.Dashboard/Serialization/DashboardJsonSerializerContext.cs, src/Aspire.Dashboard/Utils/BrowserStorageKeys.cs
• affected project Aspire.Dashboard
native-dashboard-validation • tests/Aspire.Dashboard.Playwright.Tests/Integration/Playwright/Infrastructure/DashboardServerFixture.cs
• affected project Aspire.Dashboard

Selection computed for commit 22be5f0.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed because unpublished findings identify ordering risks in move compaction after anchor removal and ambiguous replay when replicas share persistent keys.

No open issues 🎉

2 resolved since last review
3 files not reviewed
  • src/Aspire.Dashboard/Resources/Layout.Designer.cs: Generated file
  • src/Aspire.Dashboard/Resources/Metrics.Designer.cs: Generated file
  • src/Aspire.Dashboard/Resources/Resources.Designer.cs: Generated file

Review effort: Max

@JamesNK
James Newton-King (JamesNK) merged commit 1fbded1 into main Nov 24, 2026
162 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.1 milestone Nov 24, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #2245

Generated by PR Documentation Check · copilot · auto (Claude Sonnet 5.5) · ~28 AIC · ⌖ ~10 AIC · ⊞ 7.6K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#2245 targeting release/17.1.

Updated dashboard/explore.mdx (stable default ordering, only explicit drags saved) and dashboard/data-persistence.mdx (browser settings now protected, legacy plaintext not migrated). Signals: pr_body_has_user_facing_section (the "User-facing usage" section), pr_body_has_deprecation_marker (the TODO about clearing obsolete pins), new_public_type (MetricPinButton.razor.cs), pr_body_has_cli_flag_mention (the test commands, likely a false positive).

Note

This draft PR needs human review before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants