fix(ui): refresh transport status labels after a Transport Mode switch settles#48
Open
dehuaichendragonplus wants to merge 1 commit into
Conversation
…h settles Switching to/from Broker Mode restarts the server asynchronously, but the MCP Server window refreshed its status labels on a fixed 2-frame delayCall that raced the async broker bring-up. After a switch to broker mode the header kept showing "Running on …" and the transport line kept showing "Transport: Direct HTTP." even though the server had already switched (broker process owning the port, editor attached as a client). The refresh now runs once StopAsync/StartAsync have completed (awaited, so it resumes on the editor main thread against the settled transport state) instead of on a fixed delay. It also correctly reflects a direct-HTTP fallback when broker mode fails to start. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Switching the MCP Server window's Transport Mode between Direct HTTP and Broker Mode restarts the server asynchronously (
StopAsync→StartAsync, and broker bring-up spawns a process + health-probes + attaches over several frames). But the two status labels were refreshed on a fixed 2-framedelayCall, which fires long before the async restart settles:So after switching to Broker Mode the header kept showing "Running on …" and the transport line kept showing "Transport: Direct HTTP.", even though the server had already switched (a broker process owning the port, the editor attached to it as a client).
Verified on a live editor: with the server actually in broker mode (
IsAttachedToExistingTransport == true, a broker process listening on 8765, the editor connected to it), the labels still read the pre-switch Direct-HTTP text. It's a stale display, not a wrong computation — a fresh refresh produces the correct text.What changed
FunplayMCPServerControlsPanelnow refreshes the labels once the restart has actually settled instead of on a fixed delay: the transport-mode change handler awaitsStopAsync/StartAsync, then callsUpdateBrokerStatus()+ the header refresh. Awaiting captures the editor main-threadSynchronizationContext, so the refresh runs on the main thread against the final transport state. This also makes the labels correctly show a direct-HTTP fallback when broker mode fails to start (the settled state), which the old racing refresh could miss.No recurring polling is introduced on purpose:
MCPBrokerProcessManager.IsRunningdoes a synchronous loopback health probe, so polling it every frame/second would risk stalling the editor UI thread when the broker is unreachable — the refresh stays event-driven, just correctly timed.Testing
6000.3.13f1.Independence
Touches only
Editor/MCP/Server/FunplayMCPServerControlsPanel.cs. No overlap with the other open PRs; applies cleanly on currentmain.Changelog
Added under
## Unreleased(Fixed).🤖 Generated with Claude Code