fix(extension): pass client name on token-bypass connect#41845
Open
cipheraxat wants to merge 2 commits into
Open
fix(extension): pass client name on token-bypass connect#41845cipheraxat wants to merge 2 commits into
cipheraxat wants to merge 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-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.
Author
|
Updated @yury-s per review feedback: |
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)