Repository navigation
fix(extension): pass client name on token-bypass connect - #41845
Merged
Yury Semikhatsky (yury-s) merged 2 commits intoJul 20, 2026
Merged
Yury Semikhatsky (yury-s) merged 2 commits into
Yury Semikhatsky (yury-s) merged 2 commits into
Conversation
Token-bypass called handleConnectToTab in the same effect as setClientInfo, so the callback still closed over the initial "unknown" name. Pass the parsed client name explicitly and assert it on the status page.
Yury Semikhatsky (yury-s)
requested changes
Jul 17, 2026
| const handleConnectToTab = useCallback(async (tab?: chrome.tabs.Tab) => { | ||
| const handleConnectToTab = useCallback(async (tab?: chrome.tabs.Tab, clientNameOverride?: string) => { | ||
| setShowTabList(false); | ||
| const name = clientNameOverride ?? clientInfo; |
Member
There was a problem hiding this comment.
This is just a band-aid both of clientNameOverride and clientInfo are the same, so this is a workaround for the react stale closure bug.
The client name comes from window.location.search, which never changes for the lifetime of the page. Let's parse it once outside the component (or in a useMemo) and use it as a plain constant:
const clientInfo = (() => {
try {
return JSON.parse(new URLSearchParams(window.location.search).get('client') || '{}').name || 'unknown';
} catch {
return 'unknown';
}
})();Address review feedback: avoid a clientNameOverride workaround for the React stale closure by treating the URL-derived client name as a module constant, since it never changes for the page lifetime.
Contributor
Author
|
Updated Yury Semikhatsky (@yury-s) per review feedback: |
Yury Semikhatsky (yury-s)
approved these changes
Jul 20, 2026
Gabriel dos Anjos (dosxnjos)
added a commit
to dosxnjos/playwright
that referenced
this pull request
Oct 1, 2026
Ported onto the current upstream UI (3-way merge of the CSS; upstream declined it, microsoft#41841). The clientName workaround is not carried over, upstream fixed that in microsoft#41845. manifest version 0.4.0 -> 0.4.0.1 so chrome://extensions shows the fork build.
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.
Summary
handleConnectToTabwas called in the same effect that calledsetClientInfo(info), so it still closed over the initial"unknown"client name.handleConnectToTabat that call site so the status page and tab group show the real MCP client name.Connected to "token-bypass-client"on the status page.Fixes #41839
Test plan
npm run test-extension -- --grep "bypass connection"(chromium + legacy v1)npm run test-extensionsuite (2 unrelated flaky tab tests failed once, passed on rerun; bypass tests passed)