Repository navigation
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:
- Open a saved multi-root workspace containing folders A and C, and open a WinUI XAML file so the language server starts.
- Add folder B, containing another eligible WinUI project, without reloading the window.
- Open a XAML file in B and request semantic completion or hover.
- Observe that B does not receive semantic IntelliSense.
- 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