Skip to content

fix(mcp): list agents from the configured Windows Agent runtime on the phone's MCP screen - #50330

Merged
AmoabaKelvin merged 3 commits into
mainfrom
mcp-agent-discovery-host-runtime
Nov 27, 2026
Merged

AmoabaKelvin merged 3 commits into
mainfrom
mcp-agent-discovery-host-runtime

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

The phone's MCP servers screen shows which of the computer's agents a server can be turned on for. On a Windows computer set to run agents in WSL (Settings > Agents > Agent runtime), that list showed only the agents installed in Windows itself, so WSL-only agents were missing. Desktop already lists the WSL ones. Now the phone asks for the same runtime desktop uses.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​50 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​50
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​62 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​55

What Changed

  • New request field: preflight.detectAgents, refreshAgents and installedAgents take an optional configuredWindowsRuntime: true. With it and no workspace, the host probes the configured Windows Agent runtime (localWindowsRuntimeDefault), which is what desktop's own MCP pane probes when nothing is focused ([Bug]: Usage refresh in an SSH workspace overwrites AI Agent visibility with Windows-side detection results #18837).
  • How the host resolves it: with the existing resolveLocalProjectRuntimeForProject (inherit-global). It applies only on Windows with that setting explicitly set; otherwise the answer is native, as today. Combining the field with a workspace, repo or project is refused.
  • No identity still means native: older phones' Floating new-tabs and the desktop bot picker keep relying on that, so only callers that opt in change.
  • Phone MCP screen: sends the field. If the agents read fails (for example the WSL distro is stopped), the screen retries it the next time it gains focus. A healthy list keeps its 10-minute cache.
  • Stopped distro: never started for this background read (E9). The phone shows the existing "Couldn't read the agents on this computer" state, as desktop does.

Why

MCP servers are delivered per terminal launch, in Windows or in WSL, so the agents a server applies to are the ones in the runtime agents launch in. The host already knew that runtime, but a request with no workspace was answered for the native host. That default has callers that need it, so this is an opt-in field rather than a changed default.

  • Changing the default: rejected. A new host would show WSL agents for an older phone's native Floating terminal.
  • Phone sends a workspace: rejected. The MCP screen is host-scoped.

Linked Issue

N/A. This follows #46073: the same assumption (a request with no workspace is answered for the native host) that hid GitLab on the phone.

Visual Proof

N/A. The visible change is the agent list on a Windows host set to WSL, which I can't run from this Mac. The proof is the host-boundary regression test, which runs the real params schema and the real runtime resolver.

Testing

  • src/main/runtime/rpc/methods/preflight/preflight-workspace-target.test.ts covers three cases. With the field, on Windows with the Agent runtime set to WSL Ubuntu, the host resolves the WSL runtime. Without the setting, and without the field, it stays native. The test fails with the host change reverted.

  • Older hosts: I parsed { configuredWindowsRuntime: true } with release v1.4.278's compiled detectAgents and refreshAgents schemas. Both accept the request and drop the key, so older hosts answer native as before.

  • Gates: pnpm tc:node and pnpm check:changed pass.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Every added test fails without this change and avoids the test anti-patterns

Performance

None, because the same single detection runs per read. Only the host's choice of runtime changes, and only on Windows hosts with the setting.

  • Non-Windows hosts, or no setting: the same native detection as today.
  • Phone retry: it fires only on a screen focus while the agents read is failed. A healthy screen adds no detection.
  • Loop fixed in review: an earlier version re-ran on every error-state change and looped. The final perf pass covers the fix.

Risk

  • Who's affected: only phones on hosts that opt in. Old phones and other callers send no field and keep the native answer. A new phone on an older host has the field stripped and sees today's list.
  • Riskiest part: a Windows host whose WSL distro is stopped. The phone's MCP agent section then shows the existing read error instead of a native list, until the distro runs and the screen regains focus.
  • Back out: plain revert.

Level: Low

AI Disclosure

Review

review-loop ran two rounds with Codex and a Claude reviewer, each with a perf pass.

  • Round 1: found the focus-retry loop (fixed). It also found that a paired-desktop MCP inventory bucket I had added split native dedupe on hosts where both buckets mean native. That part was removed, so paired desktop stays native as today.
  • Round 2: covers the final code.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…the phone and paired desktop

The phone's MCP screen and a desktop paired to a Windows host asked
preflight.detectAgents with no workspace, which the host answers for the
native host, while desktop's own MCP pane follows the configured Agent
runtime (#18837). An opt-in configuredWindowsRuntime flag resolves that
runtime on the host; without it, no identity still means native, and older
hosts strip the flag. The phone also retries a failed agents read on focus.
…desktop native

Read the agents query state inside the stable focus callback so an error
transition cannot re-run it, and drop the paired-desktop scoped inventory:
its bucket split native dedupe on hosts where both mean native.
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Preflight agent detection can now select a configured Windows runtime when the request includes configuredWindowsRuntime: true. The schema rejects this option with worktree, repository, or project selectors. The mobile agent query sends the option and refetches agents on focus when the query status is error.

Merge Risk: Minimal · up to b806f

This adds an opt-in way for the phone's MCP screen to list agents from the configured Windows runtime, and it retries a failed read when the screen regains focus. Callers that do not opt in keep native behavior. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the phone's MCP screen now lists agents from the configured Windows Agent runtime (WSL). It uses the fix(mcp) convention and is specific enough for a teammate scanning…
Description check Passed The description follows the template sections: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checkli…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the phone's MCP screen now lists agents from the configured Windows Agent runtime (WSL). It uses the fix(mcp) convention and is specific enough for a teammate scanning history. It is a long title at 89 characters, which is acceptable.

Full details: Description check

Explanation

The description follows the template sections: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. It explains the mechanism, the opt-in design, the back-out plan, and the cross-version behavior. The Linked Issue section cites no issue number, and it says N/A. The template asks for an actual issue for outside contributors. The Risk level is set to Low. Testing reports one manual test as unchecked and gives a reason for the lack of visual proof. The 'Fixes #' line is not filled in, but the author explains why. These gaps are minor, so the description is mostly complete.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 47c1ab32-5359-4313-8db5-a48c9d19ac01
Commits

Reviewing files that changed from the base of the PR and between bfddee9 and b806f0c.

Files selected for processing: 5

  • mobile/src/mcp-servers/use-mcp-servers-data.ts
  • src/main/preflight/workspace-agent-detection.ts
  • src/main/runtime/rpc/methods/preflight/preflight-workspace-target.test.ts
  • src/main/runtime/rpc/methods/preflight/preflight-workspace-target.ts
  • src/shared/rpc-contract/preflight/preflight-params.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@AmoabaKelvin
AmoabaKelvin merged commit 1a5fc36 into main Nov 27, 2026
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant