Skip to content

Fix misleading "no longer running" state detail when container fails to start#16747

Open
Copilot wants to merge 3 commits intomainfrom
copilot/fix-misleading-state-detail
Open

Fix misleading "no longer running" state detail when container fails to start#16747
Copilot wants to merge 3 commits intomainfrom
copilot/fix-misleading-state-detail

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 4, 2026

Description

Resources in FailedToStart state showed "Container is no longer running" as the state detail — misleading because the resource never ran. This adds a dedicated state detail path for FailedToStart resources.

Root cause: IsStopped() includes FailedToStart, so GetResourceStateTooltip fell through to the generic StateColumnResourceExited branch ({0} is no longer running).

Changes:

  • ResourceViewModelExtensions — Added IsFailedToStart() extension method (KnownState is KnownResourceState.FailedToStart)
  • ResourceStateViewModel.GetResourceStateTooltip — Check IsFailedToStart() before IsStopped(); return new StateColumnResourceFailedToStart string ({0} failed to start) for this case
  • Columns.resx / Columns.Designer.cs — New resource string StateColumnResourceFailedToStart = "{0} failed to start"
  • XLF files (×13) — Updated translation stubs via dotnet build /t:UpdateXlf
  • ResourceStateViewModelTests — Two new [InlineData] cases asserting FailedToStart resolves to StateColumnResourceFailedToStart, not StateColumnResourceExited

IsStopped() still includes FailedToStart (icon/command behavior is unaffected); only the tooltip/state-detail text is changed.

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
  • Does the change require an update in our Aspire docs?
Original prompt

Fix microsoft/aspire issue #16617: [13.3] Misleading State Detail when container fails to start.

Problem

In the Aspire dashboard resource details view, a container/resource with state Failed to Start currently shows the state detail text Container is no longer running. This is misleading because the resource failed to start; it was not previously running.

The current flow is:

  • ResourceDetails.AddStateDescriptionProperty(...) adds a synthetic State details property whose value comes from ResourceStateViewModel.GetResourceStateTooltip(resource, ColumnsLoc).
  • ResourceStateViewModel.GetResourceStateTooltip(...) first checks resource.IsStopped().
  • ResourceViewModelExtensions.IsStopped() currently returns true for KnownResourceState.Exited, KnownResourceState.Finished, and KnownResourceState.FailedToStart.
  • Therefore KnownResourceState.FailedToStart falls into the generic stopped/exited branch and uses Columns.StateColumnResourceExited ({0} is no longer running).

Relevant current code:

// src/Aspire.Dashboard/Extensions/ResourceViewModelExtensions.cs
public static bool IsStopped(this ResourceViewModel resource)
{
    return resource.KnownState is KnownResourceState.Exited or KnownResourceState.Finished or KnownResourceState.FailedToStart;
}
// src/Aspire.Dashboard/Model/ResourceStateViewModel.cs
internal static string GetResourceStateTooltip(ResourceViewModel resource, IStringLocalizer<Columns> loc)
{
    if (resource.IsStopped())
    {
        if (resource.TryGetExitCode(out var exitCode) && exitCode is not 0)
        {
            return loc.GetString(nameof(Columns.StateColumnResourceExitedUnexpectedly), resource.ResourceType, exitCode);
        }
        else
        {
            return loc.GetString(nameof(Columns.StateColumnResourceExited), resource.ResourceType);
        }
    }
    ...
}

Requested fix

Implement a separate state-detail text path for resources that failed to start.

Suggested approach:

  1. Add a new extension method in src/Aspire.Dashboard/Extensions/ResourceViewModelExtensions.cs, for example:
public static bool IsFailedToStart(this ResourceViewModel resource)
{
    return resource.KnownState is KnownResourceState.FailedToStart;
}
  1. Update ResourceStateViewModel.GetResourceStateTooltip(...) so FailedToStart gets its own localized message instead of using StateColumnResourceExited.

    • Check resource.IsFailedToStart() before resource.IsStopped().
    • Add a new resource string to src/Aspire.Dashboard/Resources/Columns.resx, e.g. StateColumnResourceFailedToStart.
    • Suggested English value: {0} failed to start or Resource failed to start; prefer consistency with existing state details that include resource type, so {0} failed to start is likely appropriate.
  2. Consider whether IsStopped() should continue to include FailedToStart for icon/state command behavior. The requested behavior is specifically about the state detail text, so avoid broad behavior changes unless tests indicate it is necessary.

  3. Update/add tests in tests/Aspire.Dashboard.Tests/Model/ResourceStateViewModelTests.cs to cover KnownResourceState.FailedToStart and assert that the tooltip/state detail no longer resolves to StateColumnResourceExited / {0} is no longer running, but instead resolves to the new failed-to-start resource string.

  4. Follow repository conventions:

    • Do not edit generated API files under */api/*.cs.
    • Do not change global.json, NuGet.config, package.json, or lock files.
    • Use current C# style and formatting from .editorconfig.

Validation

Run the relevant dashboard tests, especially tests/Aspire.Dashboard.Tests/Model/ResourceStateViewModelTests.cs if feasible. At minimum, ensure the new test passes and existing resource state tooltip tests continue to pass.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: What is the source of "State details" content in the Aspire dashboard? Point me to the code that sets it

Assistant: The “State details” value in the Aspire dashboard is generated in ResourceDetails.AddStateDescriptionProperty(...). It uses the same text as the resource grid state-column tooltip: ResourceStateViewModel.GetResourceStateTooltip(...).

Key path:

  1. Details panel adds a synthetic property named resource-state-description
  2. Its display name is localized as State details
  3. Its value is ResourceStateViewModel.GetResourceStateTooltip(resource, ColumnsLoc)
private void AddStateDescriptionProperty(ResourceViewModel resource)
{
    var stateViewModel = ResourceStateViewModel.GetStateViewModel(resource, ColumnsLoc);
    var s...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

Copilot AI changed the title [WIP] Fix misleading state detail for container failure Fix misleading "no longer running" state detail when container fails to start May 4, 2026
Copilot AI requested a review from karolz-ms May 4, 2026 18:23
if (resource.IsStopped())
if (resource.IsFailedToStart())
{
// Resource failed to start. It was never running, so "no longer running" would be misleading.
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.

@copilot get rid of this comment, it is not necessary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 182e954.

Copilot AI requested a review from karolz-ms May 4, 2026 18:40
@karolz-ms karolz-ms marked this pull request as ready for review May 4, 2026 18:45
Copilot AI review requested due to automatic review settings May 4, 2026 18:45
@karolz-ms karolz-ms requested review from JamesNK and adamint as code owners May 4, 2026 18:45
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

🚀 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 -- 16747

Or

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an incorrect/misleading “State details” tooltip for resources in FailedToStart by adding a dedicated localized message path, instead of falling through to the generic “no longer running” message intended for previously-running resources.

Changes:

  • Adds a ResourceViewModel.IsFailedToStart() extension and prioritizes it in ResourceStateViewModel.GetResourceStateTooltip(...).
  • Introduces a new localized string StateColumnResourceFailedToStart ("{0} failed to start") and updates XLF translation stubs.
  • Extends dashboard unit tests to assert the new tooltip behavior for FailedToStart.

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/Aspire.Dashboard.Tests/Model/ResourceStateViewModelTests.cs Adds coverage ensuring FailedToStart uses the new dedicated tooltip string.
src/Aspire.Dashboard/Model/ResourceStateViewModel.cs Updates tooltip selection logic to handle FailedToStart explicitly before the generic stopped path.
src/Aspire.Dashboard/Extensions/ResourceViewModelExtensions.cs Adds IsFailedToStart() convenience extension for state checks.
src/Aspire.Dashboard/Resources/Columns.resx Adds StateColumnResourceFailedToStart localized string.
src/Aspire.Dashboard/Resources/Columns.Designer.cs Regenerates strongly-typed accessor for the new resource string.
src/Aspire.Dashboard/Resources/xlf/Columns.cs.xlf Adds XLF entry for the new string (stub).
src/Aspire.Dashboard/Resources/xlf/Columns.de.xlf Adds XLF entry for the new string (stub).
src/Aspire.Dashboard/Resources/xlf/Columns.es.xlf Adds XLF entry for the new string (stub).
src/Aspire.Dashboard/Resources/xlf/Columns.fr.xlf Adds XLF entry for the new string (stub).
src/Aspire.Dashboard/Resources/xlf/Columns.it.xlf Adds XLF entry for the new string (stub).
src/Aspire.Dashboard/Resources/xlf/Columns.ja.xlf Adds XLF entry for the new string (stub).
src/Aspire.Dashboard/Resources/xlf/Columns.ko.xlf Adds XLF entry for the new string (stub).
src/Aspire.Dashboard/Resources/xlf/Columns.pl.xlf Adds XLF entry for the new string (stub).
src/Aspire.Dashboard/Resources/xlf/Columns.pt-BR.xlf Adds XLF entry for the new string (stub).
src/Aspire.Dashboard/Resources/xlf/Columns.ru.xlf Adds XLF entry for the new string (stub).
src/Aspire.Dashboard/Resources/xlf/Columns.tr.xlf Adds XLF entry for the new string (stub).
src/Aspire.Dashboard/Resources/xlf/Columns.zh-Hans.xlf Adds XLF entry for the new string (stub).
src/Aspire.Dashboard/Resources/xlf/Columns.zh-Hant.xlf Adds XLF entry for the new string (stub).
Files not reviewed (1)
  • src/Aspire.Dashboard/Resources/Columns.Designer.cs: Language not supported

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.

3 participants