Skip to content

[Bug]: Refresh XAML language-server roots when workspace folders change #329

Open

Description

Describe the bug

Deferred follow-up from the review of PR #276.

The XAML client snapshots vscode.workspace.workspaceFolders into initializationOptions.allowedRoots when starting the language server (src/xaml/xamlLanguageService.ts). The server initializes its trusted _allowedRoots from that snapshot. Adding a folder to an already-running multi-root workspace does not refresh this boundary, so an eligible WinUI project in the new folder can remain syntax-only until the language server is restarted.

This is distinct from #251, which concerns general project-context commands selecting only the first workspace folder. This issue concerns the XAML server's lifecycle and trusted-root snapshot after workspace-folder changes.

To Reproduce

The coworker review reported this sequence:

  1. Open a saved multi-root workspace containing folders A and C, and open a WinUI XAML file so the language server starts.
  2. Add folder B, containing another eligible WinUI project, without reloading the window.
  3. Open a XAML file in B and request semantic completion or hover.
  4. Observe that B does not receive semantic IntelliSense.
  5. Restart the WinApp XAML language server. B then works.

Current workaround: restart the XAML language server after changing workspace folders.

Expected behavior

Adding or removing workspace folders should update XAML project eligibility and trusted-root handling without a manual restart. Existing roots should recover normally, and removed roots must not retain stale semantic access.

Proposed approach

  • Subscribe to workspace-folder changes in the XAML service lifecycle.
  • Prefer a coalesced, controlled client restart using the existing start/stop path and a fresh trusted-root snapshot, unless incremental protocol support is demonstrably necessary.
  • Respect workspace trust, disabled IntelliSense, and disposal. Do not start a disabled service or widen authorization beyond current trusted roots.
  • Cancel obsolete work and clear stale project contexts, statuses, and diagnostics when roots are removed. Reopen/reassess documents through the normal client lifecycle.

Acceptance criteria

  • Adding B to an already-running A+C workspace enables semantic features for eligible WinUI projects in B without user intervention.
  • Removing B prevents subsequent project evaluation from documents no longer covered by another allowed root and clears stale semantic state.
  • Remaining roots continue working after add/remove operations, including rapid consecutive changes.
  • Untrusted workspaces and disabled IntelliSense do not start project evaluation.
  • Add client lifecycle regressions and a real multi-root integration test covering additions and removals.

Screenshots

N/A. No screenshot is attached for this specific reproduction.

OS Version and details

Reported on Windows during PR #276 review. The exact Windows build for this reproduction was not recorded. This was deferred as a non-blocking follow-up because restarting the server provides a workaround.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions