Skip to content

Prevent Aspire view from stealing sidebar focus - #19754

Merged
Adam Ratzman (adamint) merged 1 commit into
mainfrom
ellahathaway-fix-vscode-navigation-on-load
Aug 31, 2026
Merged

Prevent Aspire view from stealing sidebar focus#19754
Adam Ratzman (adamint) merged 1 commit into
mainfrom
ellahathaway-fix-vscode-navigation-on-load

Conversation

@ellahathaway

@ellahathaway Ella Hathaway (ellahathaway) commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Description

Reloading VS Code while another sidebar view was selected could activate the Aspire view and restore its hidden Activity Bar entry. AppHost discovery was calling TreeView.reveal() to auto-expand a single AppHost even while the Aspire view was hidden; VS Code activates the view container as part of that reveal.

This change preserves single-AppHost auto-expansion but defers reveal() until the Aspire view is already visible. A visibility listener performs the pending expansion when the user explicitly opens Aspire.

User-facing behavior

Selecting Explorer and running Developer: Reload Window now leaves Explorer active. Opening Aspire explicitly still shows the single workspace AppHost expanded.

Reproduction

  1. Stop all running AppHosts.
  2. Open a workspace containing exactly one AppHost.
  3. Open the AppHost project or source file and leave that editor tab open.
  4. Open the Aspire view and ensure it is in Workspace view.
  5. Switch to Explorer.
  6. Right-click the Activity Bar and uncheck Aspire so its icon is hidden.
  7. Run Developer: Reload Window and wait for AppHost discovery to finish.

Before this change, Aspire reappears in the Activity Bar and becomes the active sidebar view. After this change, Aspire remains hidden and Explorer retains focus. Re-enabling and explicitly opening Aspire still auto-expands the single AppHost.

Validation

  • extension/build.ps1
  • corepack yarn compile-tests
  • corepack yarn compile-e2e
  • corepack yarn lint
  • Focused AspireAppHostTreeProvider unit test
  • VS Code 1.135 reload-focus E2E test, red before the implementation and green afterward
  • Manual reproduction using the steps above on the original and fixed extension builds

Fixes #19746

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

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: db22aff4-7041-426f-989f-c44a072c49a8
@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 -- 19754

Or

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

@github-actions

Copy link
Copy Markdown
Contributor

Tests selector (audit mode)

The full test matrix and all jobs still run in audit mode. The tests and jobs below are what selective CI would run under enforcement.

0 / 102 test projects · 2 jobs, from 4 changed files.

Selected test projects (0 / 102)

none — no .NET test projects run for this change.

Selected jobs (2)

extension-e2e, extension-unit


How these were chosen — grouped by what changed

Job reasons

Job Triggered by
extension-e2e extension/src/test-e2e/appHostTree.e2e.test.ts, extension/src/test-e2e/helpers/vscode.ts, extension/src/test/appHostTreeView.test.ts, extension/src/views/AspireAppHostTreeProvider.ts
extension-unit extension/src/test-e2e/appHostTree.e2e.test.ts, extension/src/test-e2e/helpers/vscode.ts, extension/src/test/appHostTreeView.test.ts, extension/src/views/AspireAppHostTreeProvider.ts

Selection computed for commit 68e9343.

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.

Pull request overview

Prevents hidden Aspire views from stealing sidebar focus during VS Code reload while preserving single-AppHost auto-expansion.

Changes:

  • Defers AppHost reveal until the Aspire view is visible.
  • Adds unit coverage for visibility and disposal behavior.
  • Adds an E2E reload-focus regression test.

Reviewed changes

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

File Description
extension/src/views/AspireAppHostTreeProvider.ts Gates auto-expansion on view visibility.
extension/src/test/appHostTreeView.test.ts Tests deferred, one-time expansion.
extension/src/test-e2e/helpers/vscode.ts Adds sidebar observation helper.
extension/src/test-e2e/appHostTree.e2e.test.ts Verifies Explorer retains focus after reload.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@adamint
Adam Ratzman (adamint) merged commit 1410c1a into main Aug 31, 2026
398 checks passed
@adamint
Adam Ratzman (adamint) deleted the ellahathaway-fix-vscode-navigation-on-load branch August 31, 2026 19:26
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 13.6 milestone Aug 31, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #1598

Generated by PR Documentation Check · auto · 39.4 AIC · ⌖ 6.91 AIC · ⊞ 19.7K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#1598 targeting release/13.6.

Added a note in get-started/aspire-vscode-extension.mdx (under The Aspire view) explaining that single-AppHost auto-expansion is preserved but the view no longer auto-activates or reveals a hidden Activity Bar icon on window reload unless the user explicitly opens Aspire. Trigger signal: pr_body_has_user_facing_section (PR body includes an explicit "User-facing behavior" section describing the Explorer-vs-Aspire focus fix).

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.

[BUG] - VS Code extension forces navigation on load, even if removed from sidebar.

3 participants