Skip to content

[release/17.0] Store dashboard tags, resource order and metric pins in browser local storage - #22004

Closed
Mitch Denny (mitchdenny) wants to merge 1 commit into
mitchdenny-backport-17-0-06-pr21850from
mitchdenny-backport-17-0-07-pr21840
Closed

Mitch Denny (mitchdenny) wants to merge 1 commit into
mitchdenny-backport-17-0-06-pr21850from
mitchdenny-backport-17-0-07-pr21840

Conversation

@mitchdenny

Copy link
Copy Markdown
Member

Description

Backport of #21840 to release/17.0 (cherry-picked from f457047 with no modifications). Layer 7 of 55 in the release/17.0 backport stack; stacked on #22003.

Backport recommendation: Yes — Dashboard settings DB is new in 17.0; moving later would drop user settings. Needed before #21881.

Backport of #21840

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

… storage (#21840)

## Description

Moves the dashboard's application-level settings (resource tags,
resource and group order, and pinned metrics) out of the SQLite settings
database (`dashboard-settings.db`) and into browser `localStorage`, like
the dashboard's other preferences. These settings no longer live in the
data directory on disk, and aren't shared between browsers or users.

### What changed

- `DashboardSettingsDatabase` is removed, along with the now-unused
`DashboardRunStore.GetApplicationSettingsDirectory`.
- `ResourceTagStore`, `ResourceOrderStore` and `MetricPinStore` are now
scoped per circuit and keep their synchronous read API. Each loads once
from `localStorage` (`EnsureLoadedAsync`) under a key scoped to the
application name, built with the same `DashboardApplicationNameKey` as
the existing collapsed-resources key: `Aspire_Resources_Tags_<app>`,
`Aspire_Resources_Order_<app>` and `Aspire_Metrics_Pins_<app>`.
- A new `LocalStorageSetting<T>` owns each setting's in-memory value and
its saves:
- **Tabs don't overwrite each other.** Every tab has its own circuit but
shares `localStorage`. Changes are idempotent functions applied in
memory immediately and queued; each save re-reads the stored value,
replays the queued changes onto it, and adopts the result, so a tab also
picks up what other tabs saved.
- **Unreadable values are never silently replaced.** `StorageResult` now
tells transient read failures (`ReadFailed`: disconnected circuit, JS
errors, timeouts) apart from values that will never read
(`InvalidValue`: bad JSON, data protection mismatch, or a bug such as an
unregistered type). Transient failures block writes, and the save is
retried with backoff through `TimeProvider`. An invalid value is copied
once to `<key>_Unreadable` and then replaced, so saving keeps working.
- A load that read storage before a save completed doesn't replace the
newer saved value.
- Values are stored unprotected. Protected values are encrypted with the
dashboard's data protection key, which changes across Aspire versions
and on every run of the standalone dashboard, so they would be lost
regularly. These are names chosen by the user or reported by the app,
not secrets.
- Moves can no longer fail to save synchronously, so the "Unable to save
the resource/group order" messages and their resource strings are
removed (`.xlf` regenerated). `TryMove` and `TryMoveGroup` return
`false` when an item has no position, and the existing
reorder-unavailable toast is shown.
- `ResourcesLayout` starts loading tags and order early and waits for
them only before showing resources. `ResourceOverview` no longer waits
for pins.

### Reviewer notes

- **No migration.** Data in an existing `dashboard-settings.db` isn't
carried over. That file was added in #21412 and hasn't shipped in a
release.
- **Settings are tied to the browser origin, port included.** If an
app's dashboard is served on a different port, its tags, order and pins
don't carry over. The other browser-stored preferences already work this
way.
- Tabs pick up each other's changes when they save or load, not live.

### Tests

- Unit tests run the stores against the real `LocalBrowserStorage` over
an in-memory `localStorage`, so they cover the stored JSON and
source-generated serialization. They cover cross-tab merging, unreadable
and invalid values, retries with `FakeTimeProvider`, and the stale-load
race. The race test fails if the guard is removed.
- The shared `TestJSRuntime` gains an optional callback (replacing a
private copy). `TestLocalStorage` returns saved values like a browser,
and can simulate failed reads.
- Playwright tag tests seed `localStorage` with an init script instead
of using the server-side store.
- Ran: `Aspire.Dashboard.Tests` (2,618 passed),
`Aspire.Dashboard.Components.Tests` (1,269 passed), and the two affected
outerloop Playwright tests
(`TagHeader_SelectsTaggedResourcesAndChevronTogglesGroup`,
`ContextMenu_RepeatedTagRowsRestoreExactTriggerAndRespectLightDismissal`).

## Checklist

- Is this feature complete?
  - [x] Yes. Ready to ship.
  - [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
  - [x] 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
  - [x] 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
  - [x] No

---------

Co-authored-by: Sébastien Ros <1165805+sebastienros@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
(cherry picked from commit f457047)
@github-actions

This comment has been minimized.

@mitchdenny

Copy link
Copy Markdown
Member Author

Approved for inclusion in release/17.0. Do not merge yet.

@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 -- 22004

Or

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

@github-actions

This comment has been minimized.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-07-pr21840 branch 2 times, most recently from bf1d57c to 8500ab3 Compare November 10, 2026 07:11
@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.

@mitchdenny
Mitch Denny (mitchdenny) changed the base branch from mitchdenny-backport-17-0-06-pr21850 to mitchdenny-backport-17-0-05-pr21823 November 10, 2026 08:18
@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-07-pr21840 branch from 8500ab3 to bf1d57c Compare November 10, 2026 09:18
@mitchdenny
Mitch Denny (mitchdenny) changed the base branch from mitchdenny-backport-17-0-05-pr21823 to mitchdenny-backport-17-0-06-pr21850 November 10, 2026 10:44
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.

2 participants