improve sign in flow

This commit is contained in:
Nate Sesti 2024-06-04 09:56:13 -07:00
parent 9955039daf
commit 3eb355e1f1
2 changed files with 23 additions and 1 deletions

View file

@ -395,7 +395,7 @@ export async function getTabCompletion(
if (llm.model.includes("codestral")) {
// Codestral sometimes starts with an extra space
if (completion[0] === " " && completion[1] !== " ") {
if (suffix.startsWith("\n")) {
if (prefix.endsWith(" ") && suffix.startsWith("\n")) {
completion = completion.slice(1);
}
}

View file

@ -45,9 +45,20 @@ class VsCodeIde implements IDE {
private askedForAuth = false;
async getGitHubAuthToken(): Promise<string | undefined> {
// Saved auth token
if (this.authToken) {
return this.authToken;
}
// Try to ask silently
const session = await vscode.authentication.getSession("github", [], {
silent: true,
});
if (session) {
this.authToken = session.accessToken;
return this.authToken;
}
try {
// If we haven't asked yet, give explanation of what is happening and why
// But don't wait to return this immediately
@ -90,6 +101,17 @@ class VsCodeIde implements IDE {
"https://docs.continue.dev/reference/Model%20Providers/freetrial",
),
);
} else if (selection === "Sign in") {
const session = await vscode.authentication.getSession(
"github",
[],
{
createIfNone: true,
},
);
if (session) {
this.authToken = session.accessToken;
}
}
});
this.askedForAuth = true;