Is there a way to determine if a user is signed into Github copilot? #2587
-
I'm developing an extension and need to implement logic that branches based on whether the user has GitHub Copilot installed AND is authenticated with their GitHub account (so that they can actually use Copilot). I've tried checking if the Copilot extension is active like this:
But that only tells me if the extension is activated, which could be true even if the user isn't authenticated. Is there a more reliable method to ascertain the user's authentication status with GitHub Copilot specifically? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 5 replies
-
cc @isidorn |
Beta Was this translation helpful? Give feedback.
-
Not sure if we have some context keys for this that you could look at for your extension |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Thanks both. Is there a way to fetch these context keys programatically? I noticed there isn't a |
Beta Was this translation helpful? Give feedback.
-
Something like this seems to work for us since we cannot get that key programmatically: /**
* This is sort of a hacky way to tell if the user is signed into Copilot.
* This check only works if the user has the Copilot extension chat view open already.
* We have also considered using the "chatIsEnabled" context key, but there is no way
* to programmatically access that.
*/
export const isUserSignedToCopilot = async () => {
const models = await vscode.lm.selectChatModels({
vendor: 'copilot',
});
return models.length > 0;
}; |
Beta Was this translation helpful? Give feedback.
-
@isidorn @roblourens , we have noticed that this does not work anymore
is there any way to programmatically determine if the user is signed into copilot? |
Beta Was this translation helpful? Give feedback.
https://github.com/microsoft/vscode/blob/df54f43ef658133ff2e5886428b29bee07f693e7/src/vs/workbench/contrib/chat/common/chatContextKeys.ts#L60-L61