Skip to content

Add AppHost CodeLens and gutter decoration support#15397

Merged
joperezr merged 8 commits intomicrosoft:release/13.2from
adamint:dev/adamint/apphost-codelens-v3
Mar 19, 2026
Merged

Add AppHost CodeLens and gutter decoration support#15397
joperezr merged 8 commits intomicrosoft:release/13.2from
adamint:dev/adamint/apphost-codelens-v3

Conversation

@adamint
Copy link
Member

@adamint adamint commented Mar 19, 2026

Description

Add CodeLens and gutter decoration support for AppHost resource files in the VS Code extension. When an Aspire AppHost is running, resources defined in C# and JS/TS AppHost files now show inline status indicators and action buttons directly in the editor.

What's included

CodeLens Provider — Inline lenses above each resource showing:

  • Live resource state (Running, Starting, Stopped, Error) with health status
  • Action buttons: Start, Stop, Restart, View Logs
  • Custom resource commands from the runtime
  • Pipeline step debugging support
image image

Gutter Decoration Provider — Colored status circles in the editor gutter:

  • Green (running), blue (starting), red (error), amber (warning), gray (stopped)
  • Debounced updates on document changes
  • Togglable via aspire.enableGutterDecorations setting

AppHost Resource Parsers — Extensible parser registry for detecting resources:

  • C# parser: detects DistributedApplication.CreateBuilder / #:sdk Aspire.AppHost.Sdk, extracts .Add*("name") calls
  • JS/TS parser: detects @aspire imports / createBuilder(), extracts .add*("name") calls
  • statementStartLine computation for multi-line fluent chains (CodeLens appears at top of chain, below comments)
  • Only matches parent resources (Add* calls), not implicit child resources

Shared Utilities:

  • resourceConstants.ts — Centralized resource state, style, type, and health status constants
  • resourceStateUtils.ts — Resource state matching across AppHosts and workspace resources

Settings:

  • aspire.enableCodeLens (default: true)
  • aspire.enableGutterDecorations (default: true)

Tests

  • 235 passing (comprehensive parser, CodeLens, and resourceStateUtils test suites)
  • Parser tests cover: detection, extraction, ranges, statementStartLine, comment skipping, edge cases
  • CodeLens tests cover: state classification, action buttons, command mapping
  • ResourceStateUtils tests cover: matching logic across AppHosts and workspace resources

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?

@adamint adamint self-assigned this Mar 19, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 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/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15397

Or

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

@adamint adamint changed the base branch from main to release/13.2 March 19, 2026 17:49
… Code extension

- Add CodeLens provider showing resource state, actions (start/stop/restart), and view logs
- Add gutter decoration provider with colored status circles for resources
- Add C# and JS/TS AppHost resource parsers with registry pattern
- Add statementStartLine for multi-line fluent chain CodeLens positioning
- Add comment-skipping logic so CodeLens appears below comments, above code
- Extract shared resource state utilities and resource constants
- Add enableCodeLens and enableGutterDecorations settings
- Add comprehensive test coverage (parsers, CodeLens, resourceStateUtils)
- Only match parent resources (Add* calls), not implicit child resources (With* calls)
@adamint adamint marked this pull request as ready for review March 19, 2026 19:42
Copilot AI review requested due to automatic review settings March 19, 2026 19:42
@adamint adamint changed the title Add apphost codelens and gutter UI for pipeline steps and resources Add AppHost CodeLens and gutter decoration support Mar 19, 2026
Copy link
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

Adds editor UX in the VS Code extension to surface Aspire AppHost pipeline steps and resource state inline (CodeLens) and in the gutter (decorations), backed by lightweight parsers for C#/JS/TS AppHost files.

Changes:

  • Introduces AppHost resource parsers (C#, JS/TS) and shared resource-state constants/utilities.
  • Adds CodeLens actions (debug pipeline step, resource state/actions/logs) and gutter status dots for resources.
  • Updates tree provider to support reveal-by-resource and consistent state constants; adds/updates tests and localization/configuration.

Reviewed changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
playground/TypeScriptApps/RpsArena/aspire.config.json Adds Aspire config for the TS playground app.
playground/TypeScriptApps/RpsArena/apphost.ts Enables PgAdmin for the Postgres resource in the playground apphost.
playground/TypeScriptApps/RpsArena/.modules/transport.ts Adds JSON-RPC authentication using ASPIRE_REMOTE_APPHOST_TOKEN.
extension/src/views/AspireAppHostTreeProvider.ts Uses shared constants; adds tree reveal support (findResourceElement, getParent).
extension/src/extension.ts Registers CodeLens + gutter decoration providers and related commands/config.
extension/src/editor/AspireCodeLensProvider.ts Implements CodeLens for pipeline steps and resource state/actions.
extension/src/editor/AspireGutterDecorationProvider.ts Implements gutter status dot decorations for resources.
extension/src/editor/parsers/AppHostResourceParser.ts Adds parser registry + document selection helpers.
extension/src/editor/parsers/csharpAppHostParser.ts Regex-based C# AppHost resource/pipeline-step parsing.
extension/src/editor/parsers/jsTsAppHostParser.ts Regex-based JS/TS AppHost resource/pipeline-step parsing.
extension/src/editor/resourceConstants.ts Centralizes runtime state/style/type constants.
extension/src/editor/resourceStateUtils.ts Adds helpers to locate matching runtime resources.
extension/src/loc/strings.ts Adds CodeLens-localized strings.
extension/package.json Adds commands + settings (enableCodeLens, enableGutterDecorations).
extension/package.nls.json Adds localized strings for new settings/commands.
extension/loc/xlf/aspire-vscode.xlf Adds XLF entries for new settings/commands.
extension/src/test/parsers.test.ts Adds parser unit tests.
extension/src/test/resourceStateUtils.test.ts Adds tests for resource matching helpers.
extension/src/test/codeLens.test.ts Adds tests for CodeLens state label mapping.
extension/src/test/appHostTreeView.test.ts Updates icon tests to use shared constants.

adamint added 3 commits March 19, 2026 15:49
…ce, Unhealthy as error

- Guard --apphost flag when appHostPath is falsy in CodeLens commands
- Prefer displayName over name in two-pass resource matching
- Classify Unhealthy health status as error (not warning) to align with tree view
@DamianEdwards
Copy link
Member

Love this! Big Code Lens fan 😄
So I'm approving from a design/product POV. Will leave to others to review from code/implementation POV.

Copy link
Member

@joperezr joperezr left a comment

Choose a reason for hiding this comment

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

Let's take this as risk is low and constrained to the extension.

@joperezr joperezr merged commit 76b5976 into microsoft:release/13.2 Mar 19, 2026
258 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Mar 19, 2026
adamint added a commit that referenced this pull request Mar 23, 2026
* Add CodeLens and gutter decoration support for AppHost resources

* wip

* remove status bar strings from branch

* Add CodeLens, gutter decorations, and AppHost resource parsers for VS Code extension

- Add CodeLens provider showing resource state, actions (start/stop/restart), and view logs
- Add gutter decoration provider with colored status circles for resources
- Add C# and JS/TS AppHost resource parsers with registry pattern
- Add statementStartLine for multi-line fluent chain CodeLens positioning
- Add comment-skipping logic so CodeLens appears below comments, above code
- Extract shared resource state utilities and resource constants
- Add enableCodeLens and enableGutterDecorations settings
- Add comprehensive test coverage (parsers, CodeLens, resourceStateUtils)
- Only match parent resources (Add* calls), not implicit child resources (With* calls)

* Address Copilot review: conditional appHostPath, displayName preference, Unhealthy as error

- Guard --apphost flag when appHostPath is falsy in CodeLens commands
- Prefer displayName over name in two-pass resource matching
- Classify Unhealthy health status as error (not warning) to align with tree view

* bump extension version

* update config json
joperezr pushed a commit that referenced this pull request Mar 23, 2026
)

* Add right-click context menu on resource endpoint URLs (#15347)

Add three context menu actions for endpoint URL tree items in the
Running AppHosts tree view:
- Copy URL to Clipboard
- Open in External Browser
- Open in Simple Browser

Introduces EndpointUrlItem TreeItem subclass with contextValue
'endpointUrl' to enable context menu targeting, replacing the
generic DetailItem for endpoint URLs.

Fixes #15345

Co-authored-by: Mitch Denny <mitch@mitchdeny.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Clean up Aspire panel: context menus, loading state, welcome messages (#15375)

* Clean up Aspire panel: context menus, loading state, welcome messages

Adds initial 'loading' screen, new context menus for resources, endpoints,
apphost, and PID nodes. Consolidates previous 3 commits into one for clean
rebase onto main.

* remove unused strings

* remove comands on resources node, update string

* Add AppHost CodeLens and gutter decoration support (#15397)

* Add CodeLens and gutter decoration support for AppHost resources

* wip

* remove status bar strings from branch

* Add CodeLens, gutter decorations, and AppHost resource parsers for VS Code extension

- Add CodeLens provider showing resource state, actions (start/stop/restart), and view logs
- Add gutter decoration provider with colored status circles for resources
- Add C# and JS/TS AppHost resource parsers with registry pattern
- Add statementStartLine for multi-line fluent chain CodeLens positioning
- Add comment-skipping logic so CodeLens appears below comments, above code
- Extract shared resource state utilities and resource constants
- Add enableCodeLens and enableGutterDecorations settings
- Add comprehensive test coverage (parsers, CodeLens, resourceStateUtils)
- Only match parent resources (Add* calls), not implicit child resources (With* calls)

* Address Copilot review: conditional appHostPath, displayName preference, Unhealthy as error

- Guard --apphost flag when appHostPath is falsy in CodeLens commands
- Prefer displayName over name in two-pass resource matching
- Classify Unhealthy health status as error (not warning) to align with tree view

* bump extension version

* update config json

* Fix dashboard image in marketplace README and bump version to 1.0.6 (#15379)

* Fix dashboard image URL: dotnet -> microsoft (#15466 partial)

---------

Co-authored-by: Mitch Denny <midenn@microsoft.com>
Co-authored-by: Mitch Denny <mitch@mitchdeny.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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