fix(studio): drop the resurrected WebMCP polyfill assertion - #3556
Open
miguel-heygen wants to merge 1 commit into
Open
fix(studio): drop the resurrected WebMCP polyfill assertion#3556miguel-heygen wants to merge 1 commit into
miguel-heygen wants to merge 1 commit into
Conversation
#3516 merged from a branch cut before da6514d and brought back `expect(document).not.toHaveProperty("modelContext")`, along with the old test title. This re-applies that fix. The assertion is racy, not merely wrong. The hook awaits a dynamic import of the `@mcp-b/global` polyfill inside its mount effect, so whether `document.modelContext` exists when the assertion runs depends only on whether that import has resolved yet. `await act()` usually returns first, which is why main went green while another PR's run went red. Inserting a 100ms wait before the assertion on the current tip makes it fail every time, and the failure dump shows all five tools registered through the polyfill: the real behaviour is the opposite of what the line asserted. Installing `document.modelContext` where the browser has none is the polyfill's job. What the case is really for is that mounting does not throw, so a browser without native WebMCP still boots Studio.
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.
mainis going red at random for open PRs on one line inpackages/studio/src/webmcp/useStudioAgentTools.test.tsx.da6514d45removedexpect(document).not.toHaveProperty("modelContext")afterthe
@mcp-b/globalpolyfill fallback landed. #3516 merged from a branch cutbefore that commit and brought the line back, together with the old test title.
This re-applies
da6514d45's change to that one case; nothing else moves.Why it is flaky rather than just wrong
useStudioAgentToolsawaits a dynamicimport("@mcp-b/global")inside itsmount effect. Whether
document.modelContextexists when the assertion runsdepends only on whether that import has resolved yet, and
await act()usually returns first.
mainwon that race and went green; another PR's runlost it and went red.
Made it deterministic on the current tip by inserting a 100ms wait before the
assertion:
The failure dump shows all five tools registered through the polyfill, so the
real behaviour is the opposite of what the line asserted. Installing
document.modelContextwhere the browser has none is exactly the polyfill'sjob. What the case is actually for is that mounting does not throw, so a
browser without native WebMCP still boots Studio.
Checked for other resurrections
3337cc899is a squash with a single parent, so its diff is its full netchange to
main. Reviewed every hunk in the four files that existed before it(
StudioAgentTools.tsx,useStudioAgentTools.ts,useStudioAgentTools.test.tsx,tools/selectionTools.test.ts). Only this one hunk reverses earlier work; therest are additive, and the
selectionTools.test.tsshrink is a helperextraction into the new
webmcpTestUtils.ts. The#3514polyfill code inuseStudioAgentTools.tsis untouched.Verification
no longer depends on who wins the race.
412 passed | 1 skipped (413)files,4591 passed | 18 todo (4609)tests.oxfmt --checkandoxlintclean on the changed file; pre-commit lint,fallow and typecheck gates all passed.