Skip to content

fix(devserver): make the selected solution authoritative (backport #25702) - #25960

Closed
mergify[bot] wants to merge 18 commits into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-25702
Closed

mergify[bot] wants to merge 18 commits into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-25702

Conversation

@mergify

@mergify mergify Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #25524

This PR carries @carldebilly's commits from #25613 unchanged, plus one commit that fixes the spell-check failure stopping that draft's CI. The add-in discovery part of #25524 is a separate PR, #25700 (closes #24311). Both are needed for the reported layout to get MCP tools.

PR Type:

🐞 Bugfix

What changed? 🚀

The DevServer MCP bridge (dnx uno.devserver --mcp-app) could resolve the right solution, then launch the host with another one. In a repo where a library solution sits within the depth-3 scan and the app solution sits deeper, the host got the library solution. No app registered, and the DevServer port was written into the library's .csproj.user.

Three things combined to cause this:

  • uno_app_select_solution refused any solution outside that depth-3 scan.
  • File changes re-ran auto-discovery over the selection. A dotnet restore was enough.
  • MCP roots could degrade the session or redirect it.

A chosen solution is now authoritative. Discovery suggests candidates but never restricts the choice. From #25613:

  • Launch what was resolved. The monitor launches the resolved solution even outside its rescan. If an explicit selection goes missing, it never falls back to another solution.
  • Select any local solution. uno_app_select_solution accepts the absolute path of any .sln/.slnx on a local drive whose nearest global.json declares the Uno SDK, inside or outside the workspace. Network, device and NT-namespace paths are refused before any file-system access.
  • Keep the selection. An explicit selection survives file changes and MCP roots. If it stops resolving, the session is degraded and uno_health says why.
  • MCP roots are hints (SEP-2577). They decide where the DevServer starts when nothing runs yet, and they never replace an explicit selection.
  • --solution <path> for the MCP bridge selects the solution at startup, the same way the tool does.
  • uno_app_initialize selects its solutionPath before applying workspaceDirectory. Its result reports the workspace and solution actually served.

On top of that, docs(devserver): reword "unstarted" for the spell check changes one word in doc/articles/features/using-the-uno-mcps.md. CSpell rejected "unstarted" (line 215), which failed both Uno.UI - CI (Setup Validations) and Uno.UI - docs on #25613. The test stages behind those validations never ran there.

Agent-visible changes, from #25613:

  • uno_app_initialize's workspaceDirectory result field now reports the served workspace instead of echoing the argument, and a solutionPath field was added.
  • A bare solution=x argument is now validated and consumed instead of reaching the host.
  • WSL paths (\wsl.localhost\...) are refused as selections and ignored as roots.

Validation

  • fix(devserver): make the selected solution authoritative #25613 reports 513 passing tests in Uno.UI.DevServer.Cli.Tests and 137 in the MCP subset of Uno.UI.RemoteControl.DevServer.Tests. It also reports an end-to-end run on the reported layout that served App.slnx in 7 of 7 checks, against 2 of 7 on master.
  • On this branch I ran a clean Release build of Uno.UI.DevServer.Cli.Tests on .NET 11 RC2: 511 of 514 tests passed. The 2 failures, Given_McpRootsFallbackProcess.*_DeferredDevServerStarts, also fail on unmodified master in my checkout. They need the SolutionTemplate workspace, which my sparse checkout leaves out.
  • I did not run the spell check locally. CSpell had reported exactly one issue, on the line this branch changes.

PR Checklist ✅

  • 🧪 Added unit tests and a manual end-to-end check (in fix(devserver): make the selected solution authoritative #25613)
  • 📚 Docs have been added/updated (dev-server.md, using-the-uno-mcps.md, health-diagnostics.md, the devserver skill, spec appendices)
  • 🖼️ Validated PR Screenshots Compare Test Run results. (DevServer only; no UI change)
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests

🤖 Generated with Claude Code


This is an automatic backport of pull request #25702 done by [Mergify](https://mergify.com).

carldebilly and others added 17 commits November 3, 2026 06:42
The MCP bridge's monitor rescans the effective workspace directory (the folder of
the nearest Uno global.json) three levels deep on every cycle, and only used the
resolved solution when that rescan listed it. A solution deeper than the scan was
replaced by the first scanned solution in sorted order, and a workspace whose only
solution was deeper never launched (SolutionNotFound). A repository with the app
solution four levels below global.json and a library-only solution higher up got
the host started on the library solution, so no app ever connected.

DetermineSolutionToLaunch now returns the resolved solution whenever it exists on
disk, taking the scanned path when listed to keep its on-disk casing; the sorted
fallback applies only when no existing solution is resolved. The monitor decides
the solution before its no-solution gate, reports a resolved solution the scan
missed in DiscoveredSolutions, and logs a warning when a fallback overrides a
selection or picks among several unselected solutions.

Refs #25524

(cherry picked from commit 6329058)
uno_app_select_solution rejected any solution outside a three-level scan of the
session's workspace, so the agent could not pick a solution deeper than the scan,
outside the directory the bridge started in, or one the scan never listed.
Discovery now helps choose instead of restricting: the candidate scan only feeds
the suggestions uno_health reports. A selection is rejected only when it cannot
work: a relative, invalid, network (UNC) or device path, a file that is not a
.sln or .slnx, a missing file, or a solution whose nearest global.json declares no
Uno SDK, since the DevServer cannot start for it. That last rejection names the
global.json that applies, or says there is none, and asks to select again rather
than restart the bridge.

Network and device paths are refused before any file-system access, here and for
uno_app_initialize's workspaceDirectory: probing one authenticates the user to the
remote server, and accepting it would load code from that share.

The tool descriptions and the WorkspaceAmbiguous remediation say selection is
free, and uno_app_initialize returns a rejected solutionPath, noting that the
workspace itself was applied, instead of discarding it.

Refs #25524

(cherry picked from commit 6355584)
A file change in the workspace (global.json, a solution file, or the
project.assets.json any dotnet restore writes) re-ran auto-discovery on the
directory the session observes and ignored the selection: the session restarted
on whatever discovery picked, or stopped when it found several solutions.

A solution chosen explicitly now stays in place until another one is selected.
WorkspaceResolution gains IsExplicitSolutionSelection, set only when a solution
path is resolved (uno_app_select_solution), not by a directory override such as
--solution-dir. File changes re-resolve that solution: an SDK change in its
global.json restarts the same solution, and a solution that no longer resolves
(deleted, or its global.json lost the Uno SDK) degrades the session while staying
selected, so it starts again once it is back. A selected solution is watched in
its own workspace, or, while it does not resolve, from the folder of its nearest
global.json or nearest existing folder; candidate suggestions keep coming from the
directory the session observed when the solution was selected.

Refs #25524

(cherry picked from commit 17ea2e9)
MCP roots drove the session: roots naming another workspace while one ran
degraded it, and roots arriving after an explicit selection could replace it.
MCP roots are deprecated (SEP-2577, MCP 2026-07-28) and only hint at a
workspace.

WorkspaceTransitionDecisions returns a new Ignore action for roots that would
override an explicitly selected solution (even one that does not resolve right
now), or replace or degrade another workspace whose DevServer runs; the session
logs it and keeps its workspace. Before any DevServer starts (deferred roots
startup, uno_app_initialize), roots still decide where it starts: a resolved
roots workspace now starts instead of leaving the unused startup one in place,
which waited for a connection that never came.

Refs #25524

(cherry picked from commit 41a1054)
With MCP roots deprecated, an MCP server configuration needs another way to
name the solution to serve: `--mcp-app --solution <path>` (or
`mcp serve --solution <path>`) selects it explicitly at startup, as
uno_app_select_solution does, and it stays selected across file changes. It wins
over --solution-dir, and it does not wait for roots under --force-roots-fallback
since roots could not change it.

The option was previously forwarded as is to the DevServer host, after the
bridge's own --solution. The bridge now consumes every spelling the host's
command-line configuration reads as that key (--solution=path, /solution, any
casing), refuses it when given more than once, and applies the checks
uno_app_select_solution does, now shared in SolutionPathRules: a local path to an
existing .sln or .slnx. An unusable path exits with code 2.

An explicit selection that does not resolve now keeps its path in the
resolution, so it stays selected, watched and reported until its global.json
declares the Uno SDK.

Refs #25524

(cherry picked from commit dc9c010)
A change of the Uno SDK version in the global.json of an explicitly selected
solution restarts the DevServer on that same solution with the new SDK; this
pins it, as the workspace transition matrix of spec 001 states.

Refs #25524

(cherry picked from commit 337e27d)
uno_app_select_solution accepts any local .sln/.slnx whose nearest global.json
declares the Uno SDK, candidates are suggestions, an explicit selection (the
tool or --solution) stays in place across file changes and MCP roots, and MCP
roots, now deprecated, only hint where the DevServer starts. The health
diagnostics, the dev-server and MCP articles (which now list
uno_app_select_solution among the always-available tools), the devserver skill,
and the workspace resolution and transition matrices of spec 001 (including the
Ignore and Diagnose actions) say so; spec 002 and the CLI reference list
--solution.

Refs #25524

(cherry picked from commit 4bc1ea3)

# Conflicts:
#	doc/articles/dev-server.md
LocalPathGuard refused roots starting with two separators, which
\??\UNC\server\share bypassed: probing it authenticates the user to that
server. On Windows it now accepts only a drive-rooted path (X:\), so no
UNC, device or NT-namespace prefix gets through.

MCP roots are now guarded too, after normalization to a full path; a
refused or unresolvable root (including one containing NUL) falls
through to the next one. The workspaceDirectory of uno_app_initialize is
checked on its full path, so \repo on the current drive is accepted.

(cherry picked from commit 9d64cfe)
When an explicitly selected solution (uno_app_select_solution,
--solution, or the solutionPath of uno_app_initialize) no longer exists,
the monitor fell back to the first scanned solution, serving one the
user did not choose. It now launches nothing and reports the solution
missing until it exists again or another is selected; the warning is
logged once until then, not every rescan. Auto-discovered selections keep
the sorted fallback.

(cherry picked from commit a4248d5)
uno_app_initialize applied workspaceDirectory as the MCP roots before
selecting its optional solutionPath, so the roots could start another
solution first, and a rejected selection claimed the workspaceDirectory
was being served even when the roots were ignored.

The solution is now selected first, with candidate solutions suggested
from workspaceDirectory; the roots applied next are ignored once a
selection is explicit. The answer reports the workspace and solution
actually served (no workspace while an explicit selection does not
resolve), and a rejection points to uno_health instead of guessing.

(cherry picked from commit 2fe01d4)
uno_app_select_solution, the --solution warning and uno_health each
explained a selection that does not resolve differently, and health gave
none at all: it said to wait for a host that would not come. One issue
now names the cause (missing file, the nearest global.json without a
usable Uno SDK, or no global.json), keeps the WorkspaceNotResolved code,
and says whether fixing it is enough (a kept selection) or the solution
must be selected again (a rejected one).

uno_health raises it for an explicit selection that does not resolve or
whose file the monitor no longer finds, instead of the wait advice; the
monitor's flag is reset between runs so it cannot outlive its selection.

(cherry picked from commit 4edb7ee)
The DevServer host reads its configuration from the command line, where
a bare solution=path sets the same key as --solution. Forwarded by the
MCP bridge after its own --solution, it replaced the bridge's choice
without its checks; the bridge now consumes it like the other spellings.
A bare "solution" with no value stays a positional argument.

The docs state the limits of a selection: --solution must be a usable
local solution (exit code 2 otherwise), and MCP roots never replace an
explicit selection or a workspace whose DevServer runs or failed, use
the first local root, and ignore roots on a network share.

(cherry picked from commit 8bbb69a)
No behavior change. Tests call ProxyLifecycleManager's
GetWorkspaceObservationRoot and EnsureDevServerStartedFromSolutionDirectory
(now internal) instead of reflecting on them, and one more test reuses
the deep-layout and session helpers. ResolveSolutionAsync builds its
unresolved result in one place, SelectSolutionAsync's path rejections
share RejectPath, and IsSolutionFile reads the extension once.

(cherry picked from commit cf40044)
CSpell rejects "unstarted" in using-the-uno-mcps.md, which failed the docs and CI validations.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit e370ad8)
Drop null-conditionals on values already known non-null and stop
Path.Combine from silently dropping a base path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 33b2513)
Clears the remaining code scanning findings on the test helpers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 01555b0)
Clears the last code scanning findings on this change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 0aa1a1e)
@mergify mergify Bot added the conflicts Automated merge hit conflicts label Nov 3, 2026
@mergify

mergify Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Cherry-pick of 4bc1ea3 has failed:

On branch mergify/bp/release/stable/6.7/pr-25702
Your branch is ahead of 'origin/release/stable/6.7' by 6 commits.
  (use "git push" to publish your local commits)

You are currently cherry-picking commit 4bc1ea3.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   .claude/skills/devserver/SKILL.md
	modified:   doc/articles/features/using-the-uno-mcps.md
	modified:   specs/001-fast-devserver-startup/spec-appendix-i-workspace-resolution-matrix.md
	modified:   specs/001-fast-devserver-startup/spec-appendix-j-workspace-transition-matrix.md
	modified:   specs/002-mcp-setup/spec.md
	modified:   src/Uno.UI.DevServer.Cli/health-diagnostics.md

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   doc/articles/dev-server.md

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Keeps the 6.7 text of the --solution-dir option and adds the --solution
option line that #25702 adds. The
other lines in the conflict came from earlier master-only doc changes and
stay out of 6.7.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@agneszitte

Copy link
Copy Markdown
Member

Superseded by #25972, the Mergify backport of #25741, already merged into release/stable/6.7 with the same DevServer code.

@agneszitte agneszitte closed this Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts Automated merge hit conflicts kind/documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants