Free Trial Auth (#1367)
* 🎨 pass gh auth token to free trial * 💄 improved onboarding flow * 🎨 make fewer auth reqs * 🎨 refactor ordering of vscode deps * 🐛 resolve confighandler
This commit is contained in:
parent
f0b2060ad8
commit
683d53bcc2
26 changed files with 439 additions and 247 deletions
|
|
@ -1,30 +1,33 @@
|
|||
import {
|
||||
ContextProviderWithParams,
|
||||
ModelDescription,
|
||||
SerializedContinueConfig,
|
||||
} from "../index.js";
|
||||
|
||||
export const FREE_TRIAL_MODELS: ModelDescription[] = [
|
||||
{
|
||||
title: "GPT-4o (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "gpt-4o",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
{
|
||||
title: "Llama3 70b (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "llama3-70b",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses. Whenever you write a code block you include the language after the opening ticks.",
|
||||
},
|
||||
{
|
||||
title: "Claude 3 Sonnet (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "claude-3-sonnet-20240229",
|
||||
},
|
||||
];
|
||||
|
||||
export const defaultConfig: SerializedContinueConfig = {
|
||||
models: [
|
||||
{
|
||||
title: "GPT-4o (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "gpt-4o",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
{
|
||||
title: "Llama3 70b (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "llama3-70b",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses. Whenever you write a code block you include the language after the opening ticks.",
|
||||
},
|
||||
{
|
||||
title: "Claude 3 Sonnet (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "claude-3-sonnet-20240229",
|
||||
},
|
||||
],
|
||||
models: FREE_TRIAL_MODELS,
|
||||
customCommands: [
|
||||
{
|
||||
name: "test",
|
||||
|
|
@ -41,27 +44,7 @@ export const defaultConfig: SerializedContinueConfig = {
|
|||
};
|
||||
|
||||
export const defaultConfigJetBrains: SerializedContinueConfig = {
|
||||
models: [
|
||||
{
|
||||
title: "GPT-4o (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "gpt-4o",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
{
|
||||
title: "Llama3 70b (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "llama3-70b",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses. Whenever you write a code block you include the language after the opening ticks.",
|
||||
},
|
||||
{
|
||||
title: "Claude 3 Sonnet (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "claude-3-sonnet-20240229",
|
||||
},
|
||||
],
|
||||
models: FREE_TRIAL_MODELS,
|
||||
customCommands: [
|
||||
{
|
||||
name: "test",
|
||||
|
|
|
|||
|
|
@ -19,12 +19,10 @@ export class ConfigHandler {
|
|||
private readonly ide: IDE,
|
||||
private ideSettingsPromise: Promise<IdeSettings>,
|
||||
private readonly writeLog: (text: string) => Promise<void>,
|
||||
private readonly onConfigUpdate: () => void,
|
||||
) {
|
||||
this.ide = ide;
|
||||
this.ideSettingsPromise = ideSettingsPromise;
|
||||
this.writeLog = writeLog;
|
||||
this.onConfigUpdate = onConfigUpdate;
|
||||
try {
|
||||
this.loadConfig();
|
||||
} catch (e) {
|
||||
|
|
@ -37,11 +35,18 @@ export class ConfigHandler {
|
|||
this.reloadConfig();
|
||||
}
|
||||
|
||||
private updateListeners: (() => void)[] = [];
|
||||
onConfigUpdate(listener: () => void) {
|
||||
this.updateListeners.push(listener);
|
||||
}
|
||||
|
||||
reloadConfig() {
|
||||
this.savedConfig = undefined;
|
||||
this.savedBrowserConfig = undefined;
|
||||
this.loadConfig();
|
||||
this.onConfigUpdate();
|
||||
for (const listener of this.updateListeners) {
|
||||
listener();
|
||||
}
|
||||
}
|
||||
|
||||
async getSerializedConfig(): Promise<BrowserSerializedContinueConfig> {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import TransformersJsEmbeddingsProvider from "../indexing/embeddings/Transformer
|
|||
import { AllEmbeddingsProviders } from "../indexing/embeddings/index.js";
|
||||
import { BaseLLM } from "../llm/index.js";
|
||||
import CustomLLMClass from "../llm/llms/CustomLLM.js";
|
||||
import FreeTrial from "../llm/llms/FreeTrial.js";
|
||||
import { llmFromDescription } from "../llm/llms/index.js";
|
||||
import { IdeSettings } from "../protocol/ideWebview.js";
|
||||
import { fetchwithRequestOptions } from "../util/fetchWithOptions.js";
|
||||
|
|
@ -277,6 +278,17 @@ async function intermediateToFinalConfig(
|
|||
};
|
||||
}
|
||||
|
||||
// Obtain auth token (only if free trial being used)
|
||||
const freeTrialModels = models.filter(
|
||||
(model) => model.providerName === "free-trial",
|
||||
);
|
||||
if (freeTrialModels.length > 0) {
|
||||
const ghAuthToken = await ide.getGitHubAuthToken();
|
||||
for (const model of freeTrialModels) {
|
||||
(model as FreeTrial).setupGhAuthToken(ghAuthToken);
|
||||
}
|
||||
}
|
||||
|
||||
// Tab autocomplete model
|
||||
let autocompleteLlm: BaseLLM | undefined = undefined;
|
||||
if (config.tabAutocompleteModel) {
|
||||
|
|
|
|||
|
|
@ -1,31 +1,12 @@
|
|||
import { SerializedContinueConfig } from "../index.js";
|
||||
import { FREE_TRIAL_MODELS } from "./default.js";
|
||||
|
||||
export function setupOptimizedMode(
|
||||
export function setupApiKeysMode(
|
||||
config: SerializedContinueConfig,
|
||||
): SerializedContinueConfig {
|
||||
return {
|
||||
...config,
|
||||
models: [
|
||||
{
|
||||
title: "GPT-4o (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "gpt-4o",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
{
|
||||
title: "Llama3 70b (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "llama3-70b",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses. Whenever you write a code block you include the language after the opening ticks.",
|
||||
},
|
||||
{
|
||||
title: "Claude 3 Sonnet (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "claude-3-sonnet-20240229",
|
||||
},
|
||||
],
|
||||
models: config.models.filter((model) => model.provider !== "free-trial"),
|
||||
tabAutocompleteModel: {
|
||||
title: "Tab Autocomplete",
|
||||
provider: "free-trial",
|
||||
|
|
@ -89,6 +70,29 @@ export function setupLocalMode(
|
|||
};
|
||||
}
|
||||
|
||||
export function setupFreeTrialMode(
|
||||
config: SerializedContinueConfig,
|
||||
): SerializedContinueConfig {
|
||||
return {
|
||||
...config,
|
||||
models: [
|
||||
...FREE_TRIAL_MODELS,
|
||||
...config.models.filter((model) => model.provider !== "free-trial"),
|
||||
],
|
||||
tabAutocompleteModel: {
|
||||
title: "Tab Autocomplete",
|
||||
provider: "free-trial",
|
||||
model: "starcoder-7b",
|
||||
},
|
||||
embeddingsProvider: {
|
||||
provider: "free-trial",
|
||||
},
|
||||
reranker: {
|
||||
name: "free-trial",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function setupLocalAfterFreeTrial(
|
||||
config: SerializedContinueConfig,
|
||||
): SerializedContinueConfig {
|
||||
|
|
|
|||
20
core/core.ts
20
core/core.ts
|
|
@ -3,10 +3,11 @@ import { ContextItemId, IDE } from ".";
|
|||
import { CompletionProvider } from "./autocomplete/completionProvider";
|
||||
import { ConfigHandler } from "./config/handler";
|
||||
import {
|
||||
setupApiKeysMode,
|
||||
setupFreeTrialMode,
|
||||
setupLocalAfterFreeTrial,
|
||||
setupLocalMode,
|
||||
setupOptimizedExistingUserMode,
|
||||
setupOptimizedMode,
|
||||
} from "./config/onboarding";
|
||||
import { addModel, addOpenAIKey, deleteModel } from "./config/util";
|
||||
import { ContinueServerClient } from "./continueServer/stubs/client";
|
||||
|
|
@ -55,12 +56,15 @@ export class Core {
|
|||
constructor(
|
||||
private readonly messenger: IMessenger<ToCoreProtocol, FromCoreProtocol>,
|
||||
private readonly ide: IDE,
|
||||
private readonly onWrite: (text: string) => Promise<void> = async () => {},
|
||||
) {
|
||||
const ideSettingsPromise = messenger.request("getIdeSettings", undefined);
|
||||
this.configHandler = new ConfigHandler(
|
||||
this.ide,
|
||||
ideSettingsPromise,
|
||||
async (text: string) => {},
|
||||
this.onWrite,
|
||||
);
|
||||
this.configHandler.onConfigUpdate(
|
||||
(() => this.messenger.send("configUpdate", undefined)).bind(this),
|
||||
);
|
||||
|
||||
|
|
@ -469,11 +473,13 @@ export class Core {
|
|||
editConfigJson(
|
||||
mode === "local"
|
||||
? setupLocalMode
|
||||
: mode === "localAfterFreeTrial"
|
||||
? setupLocalAfterFreeTrial
|
||||
: mode === "optimized"
|
||||
? setupOptimizedMode
|
||||
: setupOptimizedExistingUserMode,
|
||||
: mode === "freeTrial"
|
||||
? setupFreeTrialMode
|
||||
: mode === "localAfterFreeTrial"
|
||||
? setupLocalAfterFreeTrial
|
||||
: mode === "apiKeys"
|
||||
? setupApiKeysMode
|
||||
: setupOptimizedExistingUserMode,
|
||||
);
|
||||
this.configHandler.reloadConfig();
|
||||
});
|
||||
|
|
|
|||
1
core/index.d.ts
vendored
1
core/index.d.ts
vendored
|
|
@ -430,6 +430,7 @@ export interface IDE {
|
|||
getGitRootPath(dir: string): Promise<string | undefined>;
|
||||
listDir(dir: string): Promise<[string, FileType][]>;
|
||||
getLastModified(files: string[]): Promise<{ [path: string]: number }>;
|
||||
getGitHubAuthToken(): Promise<string | undefined>;
|
||||
}
|
||||
|
||||
// Slash Commands
|
||||
|
|
|
|||
|
|
@ -8,9 +8,21 @@ import { streamResponse } from "../stream.js";
|
|||
class FreeTrial extends BaseLLM {
|
||||
static providerName: ModelProvider = "free-trial";
|
||||
|
||||
private ghAuthToken: string | undefined = undefined;
|
||||
|
||||
setupGhAuthToken(ghAuthToken: string | undefined) {
|
||||
this.ghAuthToken = ghAuthToken;
|
||||
}
|
||||
|
||||
private async _getHeaders() {
|
||||
if (!this.ghAuthToken) {
|
||||
throw new Error(
|
||||
"Please sign in with GitHub in order to use the free trial. If you'd like to use Continue without signing in, you can set up your own local model or API key.",
|
||||
);
|
||||
}
|
||||
return {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${this.ghAuthToken}`,
|
||||
...(await getHeaders()),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,8 +124,9 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
{
|
||||
mode:
|
||||
| "local"
|
||||
| "optimized"
|
||||
| "apiKeys"
|
||||
| "custom"
|
||||
| "freeTrial"
|
||||
| "localExistingUser"
|
||||
| "optimizedExistingUser"
|
||||
| "localAfterFreeTrial";
|
||||
|
|
|
|||
|
|
@ -69,4 +69,6 @@ export type ToIdeFromWebviewOrCoreProtocol = {
|
|||
getGitRootPath: [{ dir: string }, string | undefined];
|
||||
listDir: [{ dir: string }, [string, FileType][]];
|
||||
getLastModified: [{ files: string[] }, { [path: string]: number }];
|
||||
|
||||
getGitHubAuthToken: [undefined, string | undefined];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & {
|
|||
insertAtCursor: [{ text: string }, void];
|
||||
copyText: [{ text: string }, void];
|
||||
"jetbrains/editorInsetHeight": [{ height: number }, void];
|
||||
setGitHubAuthToken: [{ token: string }, void];
|
||||
};
|
||||
|
||||
export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & {
|
||||
|
|
@ -64,4 +65,5 @@ export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & {
|
|||
addApiKey: [undefined, void];
|
||||
setupLocalModel: [undefined, void];
|
||||
incrementFtc: [undefined, void];
|
||||
openOnboarding: [undefined, void];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ import {
|
|||
import { getContinueGlobalPath } from "./paths.js";
|
||||
|
||||
class FileSystemIde implements IDE {
|
||||
async getGitHubAuthToken(): Promise<string | undefined> {
|
||||
return undefined;
|
||||
}
|
||||
getLastModified(files: string[]): Promise<{ [path: string]: number }> {
|
||||
return new Promise((resolve) => {
|
||||
resolve({
|
||||
|
|
@ -31,8 +34,8 @@ class FileSystemIde implements IDE {
|
|||
dirent.isDirectory()
|
||||
? FileType.Directory
|
||||
: dirent.isSymbolicLink()
|
||||
? FileType.SymbolicLink
|
||||
: FileType.File,
|
||||
? FileType.SymbolicLink
|
||||
: FileType.File,
|
||||
]);
|
||||
return Promise.resolve(all);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ export class MessageIde implements IDE {
|
|||
data: ToIdeFromWebviewOrCoreProtocol[T][0],
|
||||
) => Promise<ToIdeFromWebviewOrCoreProtocol[T][1]>,
|
||||
) {}
|
||||
getGitHubAuthToken(): Promise<string | undefined> {
|
||||
return this.request("getGitHubAuthToken", undefined);
|
||||
}
|
||||
getLastModified(files: string[]): Promise<{ [path: string]: number }> {
|
||||
return this.request("getLastModified", { files });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -478,9 +478,6 @@ const commandsMap: (
|
|||
panel.webview.html = sidebar.getSidebarContent(
|
||||
extensionContext,
|
||||
panel,
|
||||
ide,
|
||||
configHandler,
|
||||
verticalDiffManager,
|
||||
undefined,
|
||||
undefined,
|
||||
true,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import type { FileEdit, IDE } from "core";
|
||||
import type { FileEdit } from "core";
|
||||
import type { ConfigHandler } from "core/config/handler";
|
||||
import * as vscode from "vscode";
|
||||
import type { VerticalPerLineDiffManager } from "./diff/verticalPerLine/manager";
|
||||
import { getTheme } from "./util/getTheme";
|
||||
import { getExtensionVersion } from "./util/util";
|
||||
import { getExtensionUri, getNonce, getUniqueId } from "./util/vscode";
|
||||
|
|
@ -22,9 +21,6 @@ export class ContinueGUIWebviewViewProvider
|
|||
webviewView.webview.html = this.getSidebarContent(
|
||||
this.extensionContext,
|
||||
webviewView,
|
||||
this.ide,
|
||||
this.configHandler,
|
||||
this.verticalDiffManager,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -50,21 +46,21 @@ export class ContinueGUIWebviewViewProvider
|
|||
}
|
||||
|
||||
constructor(
|
||||
private readonly configHandler: ConfigHandler,
|
||||
private readonly ide: IDE,
|
||||
private readonly configHandlerPromise: Promise<ConfigHandler>,
|
||||
private readonly windowId: string,
|
||||
private readonly extensionContext: vscode.ExtensionContext,
|
||||
private readonly verticalDiffManager: VerticalPerLineDiffManager,
|
||||
) {
|
||||
this.webviewProtocol = new VsCodeWebviewProtocol();
|
||||
this.webviewProtocol = new VsCodeWebviewProtocol(
|
||||
(async () => {
|
||||
const configHandler = await this.configHandlerPromise;
|
||||
return configHandler.reloadConfig();
|
||||
}).bind(this),
|
||||
);
|
||||
}
|
||||
|
||||
getSidebarContent(
|
||||
context: vscode.ExtensionContext | undefined,
|
||||
panel: vscode.WebviewPanel | vscode.WebviewView,
|
||||
ide: IDE,
|
||||
configHandler: ConfigHandler,
|
||||
verticalDiffManager: VerticalPerLineDiffManager,
|
||||
page: string | undefined = undefined,
|
||||
edits: FileEdit[] | undefined = undefined,
|
||||
isFullScreen = false,
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ export class VsCodeMessenger {
|
|||
>,
|
||||
private readonly webviewProtocol: VsCodeWebviewProtocol,
|
||||
private readonly ide: VsCodeIde,
|
||||
private readonly verticalDiffManager: VerticalPerLineDiffManager,
|
||||
private readonly verticalDiffManagerPromise: Promise<VerticalPerLineDiffManager>,
|
||||
) {
|
||||
/** WEBVIEW ONLY LISTENERS **/
|
||||
this.onWebview("showFile", (msg) => {
|
||||
|
|
@ -134,7 +134,7 @@ export class VsCodeMessenger {
|
|||
editor.selection = new vscode.Selection(start, end);
|
||||
}
|
||||
|
||||
this.verticalDiffManager.streamEdit(
|
||||
(await this.verticalDiffManagerPromise).streamEdit(
|
||||
`The following code was suggested as an edit:\n\`\`\`\n${msg.data.text}\n\`\`\`\nPlease apply it to the previous code.`,
|
||||
await this.webviewProtocol.request("getDefaultModelTitle", undefined),
|
||||
);
|
||||
|
|
@ -201,72 +201,72 @@ export class VsCodeMessenger {
|
|||
return ide.getIdeSettings();
|
||||
});
|
||||
this.onWebviewOrCore("getDiff", async (msg) => {
|
||||
return await ide.getDiff();
|
||||
return ide.getDiff();
|
||||
});
|
||||
this.onWebviewOrCore("getTerminalContents", async (msg) => {
|
||||
return await ide.getTerminalContents();
|
||||
return ide.getTerminalContents();
|
||||
});
|
||||
this.onWebviewOrCore("getDebugLocals", async (msg) => {
|
||||
return await ide.getDebugLocals(Number(msg.data.threadIndex));
|
||||
return ide.getDebugLocals(Number(msg.data.threadIndex));
|
||||
});
|
||||
this.onWebviewOrCore("getAvailableThreads", async (msg) => {
|
||||
return await ide.getAvailableThreads();
|
||||
return ide.getAvailableThreads();
|
||||
});
|
||||
this.onWebviewOrCore("getTopLevelCallStackSources", async (msg) => {
|
||||
return await ide.getTopLevelCallStackSources(
|
||||
return ide.getTopLevelCallStackSources(
|
||||
msg.data.threadIndex,
|
||||
msg.data.stackDepth,
|
||||
);
|
||||
});
|
||||
this.onWebviewOrCore("listWorkspaceContents", async (msg) => {
|
||||
return await ide.listWorkspaceContents();
|
||||
return ide.listWorkspaceContents();
|
||||
});
|
||||
this.onWebviewOrCore("getWorkspaceDirs", async (msg) => {
|
||||
return await ide.getWorkspaceDirs();
|
||||
return ide.getWorkspaceDirs();
|
||||
});
|
||||
this.onWebviewOrCore("listFolders", async (msg) => {
|
||||
return await ide.listFolders();
|
||||
return ide.listFolders();
|
||||
});
|
||||
this.onWebviewOrCore("writeFile", async (msg) => {
|
||||
return await ide.writeFile(msg.data.path, msg.data.contents);
|
||||
return ide.writeFile(msg.data.path, msg.data.contents);
|
||||
});
|
||||
this.onWebviewOrCore("showVirtualFile", async (msg) => {
|
||||
return await ide.showVirtualFile(msg.data.name, msg.data.content);
|
||||
return ide.showVirtualFile(msg.data.name, msg.data.content);
|
||||
});
|
||||
this.onWebviewOrCore("getContinueDir", async (msg) => {
|
||||
return await ide.getContinueDir();
|
||||
return ide.getContinueDir();
|
||||
});
|
||||
this.onWebviewOrCore("openFile", async (msg) => {
|
||||
return await ide.openFile(msg.data.path);
|
||||
return ide.openFile(msg.data.path);
|
||||
});
|
||||
this.onWebviewOrCore("runCommand", async (msg) => {
|
||||
await ide.runCommand(msg.data.command);
|
||||
});
|
||||
this.onWebviewOrCore("getSearchResults", async (msg) => {
|
||||
return await ide.getSearchResults(msg.data.query);
|
||||
return ide.getSearchResults(msg.data.query);
|
||||
});
|
||||
this.onWebviewOrCore("subprocess", async (msg) => {
|
||||
return await ide.subprocess(msg.data.command);
|
||||
return ide.subprocess(msg.data.command);
|
||||
});
|
||||
this.onWebviewOrCore("getProblems", async (msg) => {
|
||||
return await ide.getProblems(msg.data.filepath);
|
||||
return ide.getProblems(msg.data.filepath);
|
||||
});
|
||||
this.onWebviewOrCore("getBranch", async (msg) => {
|
||||
const { dir } = msg.data;
|
||||
return await ide.getBranch(dir);
|
||||
return ide.getBranch(dir);
|
||||
});
|
||||
this.onWebviewOrCore("getOpenFiles", async (msg) => {
|
||||
return await ide.getOpenFiles();
|
||||
return ide.getOpenFiles();
|
||||
});
|
||||
this.onWebviewOrCore("getCurrentFile", async () => {
|
||||
return await ide.getCurrentFile();
|
||||
return ide.getCurrentFile();
|
||||
});
|
||||
this.onWebviewOrCore("getPinnedFiles", async (msg) => {
|
||||
return await ide.getPinnedFiles();
|
||||
return ide.getPinnedFiles();
|
||||
});
|
||||
this.onWebviewOrCore("showLines", async (msg) => {
|
||||
const { filepath, startLine, endLine } = msg.data;
|
||||
return await ide.showLines(filepath, startLine, endLine);
|
||||
return ide.showLines(filepath, startLine, endLine);
|
||||
});
|
||||
// Other
|
||||
this.onWebviewOrCore("errorPopup", (msg) => {
|
||||
|
|
@ -278,5 +278,8 @@ export class VsCodeMessenger {
|
|||
}
|
||||
});
|
||||
});
|
||||
this.onWebviewOrCore("getGitHubAuthToken", (msg) =>
|
||||
ide.getGitHubAuthToken(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,48 +39,27 @@ export class VsCodeExtension {
|
|||
constructor(context: vscode.ExtensionContext) {
|
||||
this.diffManager = new DiffManager(context);
|
||||
this.ide = new VsCodeIde(this.diffManager);
|
||||
this.extensionContext = context;
|
||||
this.windowId = uuidv4();
|
||||
|
||||
const ideSettings = this.ide.getIdeSettings();
|
||||
const { remoteConfigServerUrl } = ideSettings;
|
||||
|
||||
// Config Handler with output channel
|
||||
const outputChannel = vscode.window.createOutputChannel(
|
||||
"Continue - LLM Prompt/Completion",
|
||||
);
|
||||
this.configHandler = new ConfigHandler(
|
||||
this.ide,
|
||||
Promise.resolve(ideSettings),
|
||||
async (log: string) => {
|
||||
outputChannel.appendLine(
|
||||
"==========================================================================",
|
||||
);
|
||||
outputChannel.appendLine(
|
||||
"==========================================================================",
|
||||
);
|
||||
outputChannel.append(log);
|
||||
// Dependencies of core
|
||||
let resolveVerticalDiffManager: any = undefined;
|
||||
const verticalDiffManagerPromise = new Promise<VerticalPerLineDiffManager>(
|
||||
(resolve) => {
|
||||
resolveVerticalDiffManager = resolve;
|
||||
},
|
||||
(() => this.webviewProtocol?.request("configUpdate", undefined)).bind(
|
||||
this,
|
||||
),
|
||||
);
|
||||
|
||||
this.configHandler.reloadConfig();
|
||||
this.verticalDiffManager = new VerticalPerLineDiffManager(
|
||||
this.configHandler,
|
||||
);
|
||||
this.extensionContext = context;
|
||||
this.tabAutocompleteModel = new TabAutocompleteModel(this.configHandler);
|
||||
this.windowId = uuidv4();
|
||||
let resolveConfigHandler: any = undefined;
|
||||
const configHandlerPromise = new Promise<ConfigHandler>((resolve) => {
|
||||
resolveConfigHandler = resolve;
|
||||
});
|
||||
this.sidebar = new ContinueGUIWebviewViewProvider(
|
||||
this.configHandler,
|
||||
this.ide,
|
||||
configHandlerPromise,
|
||||
this.windowId,
|
||||
this.extensionContext,
|
||||
this.verticalDiffManager,
|
||||
);
|
||||
|
||||
setupRemoteConfigSync(
|
||||
this.configHandler.reloadConfig.bind(this.configHandler),
|
||||
);
|
||||
|
||||
// Sidebar
|
||||
|
|
@ -95,9 +74,10 @@ export class VsCodeExtension {
|
|||
);
|
||||
this.webviewProtocol = this.sidebar.webviewProtocol;
|
||||
|
||||
// Indexing + pause token
|
||||
this.diffManager.webviewProtocol = this.webviewProtocol;
|
||||
|
||||
// Config Handler with output channel
|
||||
const outputChannel = vscode.window.createOutputChannel(
|
||||
"Continue - LLM Prompt/Completion",
|
||||
);
|
||||
const inProcessMessenger = new InProcessMessenger<
|
||||
ToCoreProtocol,
|
||||
FromCoreProtocol
|
||||
|
|
@ -106,9 +86,36 @@ export class VsCodeExtension {
|
|||
inProcessMessenger,
|
||||
this.webviewProtocol,
|
||||
this.ide,
|
||||
this.verticalDiffManager,
|
||||
verticalDiffManagerPromise,
|
||||
);
|
||||
this.core = new Core(inProcessMessenger, this.ide);
|
||||
this.core = new Core(inProcessMessenger, this.ide, async (log: string) => {
|
||||
outputChannel.appendLine(
|
||||
"==========================================================================",
|
||||
);
|
||||
outputChannel.appendLine(
|
||||
"==========================================================================",
|
||||
);
|
||||
outputChannel.append(log);
|
||||
});
|
||||
this.configHandler = this.core.configHandler;
|
||||
resolveConfigHandler?.(this.configHandler);
|
||||
this.configHandler.onConfigUpdate(() => {
|
||||
this.webviewProtocol?.request("configUpdate", undefined);
|
||||
});
|
||||
|
||||
this.configHandler.reloadConfig();
|
||||
this.verticalDiffManager = new VerticalPerLineDiffManager(
|
||||
this.configHandler,
|
||||
);
|
||||
resolveVerticalDiffManager?.(this.verticalDiffManager);
|
||||
this.tabAutocompleteModel = new TabAutocompleteModel(this.configHandler);
|
||||
|
||||
setupRemoteConfigSync(
|
||||
this.configHandler.reloadConfig.bind(this.configHandler),
|
||||
);
|
||||
|
||||
// Indexing + pause token
|
||||
this.diffManager.webviewProtocol = this.webviewProtocol;
|
||||
|
||||
if (
|
||||
!(
|
||||
|
|
|
|||
|
|
@ -33,6 +33,30 @@ class VsCodeIde implements IDE {
|
|||
this.ideUtils = new VsCodeIdeUtils();
|
||||
}
|
||||
|
||||
private authToken: string | undefined;
|
||||
private askedForAuth = false;
|
||||
|
||||
async getGitHubAuthToken(): Promise<string | undefined> {
|
||||
if (this.authToken) {
|
||||
return this.authToken;
|
||||
}
|
||||
try {
|
||||
const session = await vscode.authentication.getSession("github", [], {
|
||||
silent: this.askedForAuth,
|
||||
createIfNone: !this.askedForAuth,
|
||||
});
|
||||
if (session) {
|
||||
this.authToken = session.accessToken;
|
||||
return session.accessToken;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to get GitHub authentication session:", error);
|
||||
} finally {
|
||||
this.askedForAuth = true;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async infoPopup(message: string): Promise<void> {
|
||||
vscode.window.showInformationMessage(message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,6 +153,26 @@ export class VsCodeWebviewProtocol
|
|||
this.request("setupLocalModel", undefined);
|
||||
}
|
||||
});
|
||||
} else if (message.includes("Please sign in with GitHub")) {
|
||||
vscode.window
|
||||
.showInformationMessage(
|
||||
message,
|
||||
"Sign In",
|
||||
"Use API key / local model",
|
||||
)
|
||||
.then((selection) => {
|
||||
if (selection === "Sign In") {
|
||||
vscode.authentication
|
||||
.getSession("github", [], {
|
||||
createIfNone: true,
|
||||
})
|
||||
.then(() => {
|
||||
this.reloadConfig();
|
||||
});
|
||||
} else if (selection === "Use API key / local model") {
|
||||
this.request("openOnboarding", undefined);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
vscode.window
|
||||
.showErrorMessage(message, "Show Logs", "Troubleshooting")
|
||||
|
|
@ -175,7 +195,7 @@ export class VsCodeWebviewProtocol
|
|||
});
|
||||
}
|
||||
|
||||
constructor() {}
|
||||
constructor(private readonly reloadConfig: () => void) {}
|
||||
invoke<T extends keyof ToCoreOrIdeFromWebviewProtocol>(
|
||||
messageType: T,
|
||||
data: ToCoreOrIdeFromWebviewProtocol[T][0],
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import useSubmenuContextProviders from "./hooks/useSubmenuContextProviders";
|
|||
import { useVscTheme } from "./hooks/useVscTheme";
|
||||
import GUI from "./pages/gui";
|
||||
import LocalOnboarding from "./pages/localOnboarding";
|
||||
import ApiKeyOnboarding from "./pages/onboarding/apiKeyOnboarding";
|
||||
import ExistingUserOnboarding from "./pages/onboarding/existingUserOnboarding";
|
||||
import Onboarding from "./pages/onboarding/onboarding";
|
||||
import Stats from "./pages/stats";
|
||||
|
|
@ -83,6 +84,10 @@ const router = createMemoryRouter([
|
|||
path: "/migration",
|
||||
element: <MigrationPage />,
|
||||
},
|
||||
{
|
||||
path: "/apiKeyOnboarding",
|
||||
element: <ApiKeyOnboarding />,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import { defaultModelSelector } from "../redux/selectors/modelSelectors";
|
|||
import {
|
||||
setBottomMessage,
|
||||
setBottomMessageCloseTimeout,
|
||||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../redux/slices/uiStateSlice";
|
||||
import { RootState } from "../redux/store";
|
||||
|
|
@ -31,7 +30,6 @@ import { ftl } from "./dialogs/FTCDialog";
|
|||
import IndexingProgressBar from "./loaders/IndexingProgressBar";
|
||||
import ProgressBar from "./loaders/ProgressBar";
|
||||
import ModelSelect from "./modelSelection/ModelSelect";
|
||||
import QuickModelSetup from "./modelSelection/quickSetup/QuickModelSetup";
|
||||
|
||||
// #region Styled Components
|
||||
const FOOTER_HEIGHT = "1.8em";
|
||||
|
|
@ -93,7 +91,9 @@ const DropdownPortalDiv = styled.div`
|
|||
const HIDE_FOOTER_ON_PAGES = [
|
||||
"/onboarding",
|
||||
"/existingUserOnboarding",
|
||||
"/onboarding",
|
||||
"/localOnboarding",
|
||||
"/apiKeyOnboarding",
|
||||
];
|
||||
|
||||
const Layout = () => {
|
||||
|
|
@ -175,8 +175,15 @@ const Layout = () => {
|
|||
useWebviewListener(
|
||||
"addApiKey",
|
||||
async () => {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(setDialogMessage(<QuickModelSetup />));
|
||||
navigate("/apiKeyOnboarding");
|
||||
},
|
||||
[navigate],
|
||||
);
|
||||
|
||||
useWebviewListener(
|
||||
"openOnboarding",
|
||||
async () => {
|
||||
navigate("/onboarding");
|
||||
},
|
||||
[navigate],
|
||||
);
|
||||
|
|
@ -212,11 +219,7 @@ const Layout = () => {
|
|||
!location.pathname.startsWith("/onboarding") &&
|
||||
!location.pathname.startsWith("/existingUserOnboarding")
|
||||
) {
|
||||
if (getLocalStorage("mainTextEntryCounter")) {
|
||||
navigate("/existingUserOnboarding");
|
||||
} else {
|
||||
navigate("/onboarding");
|
||||
}
|
||||
navigate("/onboarding");
|
||||
}
|
||||
}, [location]);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import ReactDOM from "react-dom";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import { StyledTooltip, lightGray, vscForeground } from "..";
|
||||
import {
|
||||
|
|
@ -52,6 +53,7 @@ interface ProgressBarProps {
|
|||
|
||||
const ProgressBar = ({ completed, total }: ProgressBarProps) => {
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
const fillPercentage = Math.min(100, Math.max(0, (completed / total) * 100));
|
||||
|
||||
const tooltipPortalDiv = document.getElementById("tooltip-portal-div");
|
||||
|
|
@ -62,7 +64,16 @@ const ProgressBar = ({ completed, total }: ProgressBarProps) => {
|
|||
data-tooltip-id="usage_progress_bar"
|
||||
onClick={() => {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(setDialogMessage(<QuickModelSetup />));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<QuickModelSetup
|
||||
onDone={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
navigate("/");
|
||||
}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
}}
|
||||
>
|
||||
<ProgressBarWrapper>
|
||||
|
|
|
|||
|
|
@ -5,13 +5,14 @@ import { useNavigate } from "react-router-dom";
|
|||
import { Button, Input, SecondaryButton } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { setDefaultModel } from "../../../redux/slices/stateSlice";
|
||||
import { setShowDialog } from "../../../redux/slices/uiStateSlice";
|
||||
import { getLocalStorage } from "../../../util/localStorage";
|
||||
import { PROVIDER_INFO } from "../../../util/modelData";
|
||||
import { ftl } from "../../dialogs/FTCDialog";
|
||||
import QuickSetupListBox from "./QuickSetupListBox";
|
||||
|
||||
interface QuickModelSetupProps {}
|
||||
interface QuickModelSetupProps {
|
||||
onDone: () => void;
|
||||
}
|
||||
|
||||
function QuickModelSetup(props: QuickModelSetupProps) {
|
||||
const [selectedProvider, setSelectedProvider] = useState(
|
||||
|
|
@ -29,14 +30,16 @@ function QuickModelSetup(props: QuickModelSetupProps) {
|
|||
setSelectedModel(selectedProvider.packages[0]);
|
||||
}, [selectedProvider]);
|
||||
|
||||
const [hasAddedModel, setHasAddedModel] = useState(false);
|
||||
|
||||
return (
|
||||
<FormProvider {...formMethods}>
|
||||
<div className="p-4">
|
||||
<h1>
|
||||
{/* <h1>
|
||||
{getLocalStorage("ftc") > ftl()
|
||||
? "Set up your own model"
|
||||
: "Add a new model"}
|
||||
</h1>
|
||||
</h1> */}
|
||||
|
||||
{getLocalStorage("ftc") > ftl() && (
|
||||
<p className="text-sm text-gray-500">
|
||||
|
|
@ -127,18 +130,16 @@ function QuickModelSetup(props: QuickModelSetupProps) {
|
|||
};
|
||||
ideMessenger.post("config/addModel", { model });
|
||||
dispatch(setDefaultModel({ title: model.title, force: true }));
|
||||
navigate("/");
|
||||
setHasAddedModel(true);
|
||||
}}
|
||||
className="w-full"
|
||||
>
|
||||
Add Model
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
navigate("/");
|
||||
}}
|
||||
onClick={props.onDone}
|
||||
className="w-full"
|
||||
disabled={!hasAddedModel}
|
||||
>
|
||||
Done
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const MAX_HISTORY_LENGTH = 100;
|
|||
|
||||
export function useInputHistory() {
|
||||
const [inputHistory, setInputHistory] = useState<JSONContent[]>(
|
||||
getLocalStorage("inputHistory").slice(-MAX_HISTORY_LENGTH) ?? [],
|
||||
getLocalStorage("inputHistory")?.slice(-MAX_HISTORY_LENGTH) ?? [],
|
||||
);
|
||||
const [pendingInput, setPendingInput] =
|
||||
useState<JSONContent>(emptyJsonContent());
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import StepContainer from "../components/gui/StepContainer";
|
|||
import TimelineItem from "../components/gui/TimelineItem";
|
||||
import ContinueInputBox from "../components/mainInput/ContinueInputBox";
|
||||
import { defaultInputModifiers } from "../components/mainInput/inputModifiers";
|
||||
import QuickModelSetup from "../components/modelSelection/quickSetup/QuickModelSetup";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import useChatHandler from "../hooks/useChatHandler";
|
||||
import useHistory from "../hooks/useHistory";
|
||||
|
|
@ -248,8 +247,7 @@ function GUI(props: GUIProps) {
|
|||
setLocalStorage("ftc", u + 1);
|
||||
|
||||
if (u >= ftl()) {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(setDialogMessage(<QuickModelSetup />));
|
||||
navigate("/onboarding");
|
||||
posthog?.capture("ftc_reached");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
33
gui/src/pages/onboarding/apiKeyOnboarding.tsx
Normal file
33
gui/src/pages/onboarding/apiKeyOnboarding.tsx
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { Cog6ToothIcon } from "@heroicons/react/24/outline";
|
||||
import { useContext } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import QuickModelSetup from "../../components/modelSelection/quickSetup/QuickModelSetup";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
|
||||
function ApiKeyOnboarding() {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const navigate = useNavigate();
|
||||
return (
|
||||
<div className="p-2 max-w-96 mt-16 mx-auto">
|
||||
<h1 className="text-center">Model Setup</h1>
|
||||
<p className="text-center">
|
||||
To get started, choose a model and enter your API key. You can always
|
||||
reconfigure later by clicking the{" "}
|
||||
<Cog6ToothIcon
|
||||
className="inline-block h-5 w-5 align-middle cursor-pointer"
|
||||
onClick={() => ideMessenger.post("openConfigJson", undefined)}
|
||||
/>{" "}
|
||||
icon in the bottom right.
|
||||
</p>
|
||||
|
||||
<QuickModelSetup
|
||||
onDone={() => {
|
||||
ideMessenger.post("showTutorial", undefined);
|
||||
navigate("/");
|
||||
}}
|
||||
></QuickModelSetup>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ApiKeyOnboarding;
|
||||
|
|
@ -1,8 +1,16 @@
|
|||
import { useContext, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { greenButtonColor } from "../../components";
|
||||
import {
|
||||
Button,
|
||||
Input,
|
||||
SecondaryButton,
|
||||
greenButtonColor,
|
||||
vscForeground,
|
||||
} from "../../components";
|
||||
import { ftl } from "../../components/dialogs/FTCDialog";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { setLocalStorage } from "../../util/localStorage";
|
||||
import { isJetBrains } from "../../util";
|
||||
import { getLocalStorage, setLocalStorage } from "../../util/localStorage";
|
||||
import { Div, StyledButton } from "./components";
|
||||
|
||||
function Onboarding() {
|
||||
|
|
@ -11,16 +19,30 @@ function Onboarding() {
|
|||
|
||||
const [hovered0, setHovered0] = useState(false);
|
||||
const [hovered1, setHovered1] = useState(false);
|
||||
const [hovered2, setHovered2] = useState(false);
|
||||
|
||||
const [selected, setSelected] = useState(-1);
|
||||
|
||||
const [jbGhAuthToken, setJbGhAuthToken] = useState("");
|
||||
|
||||
return (
|
||||
<div className="p-2 max-w-96 mt-16 mx-auto">
|
||||
<h1 className="text-center">Welcome to Continue</h1>
|
||||
<p className="text-center pb-2">
|
||||
Let's find the setup that works best for you
|
||||
</p>
|
||||
{getLocalStorage("ftc") > ftl() ? (
|
||||
<>
|
||||
<h1 className="text-center">Free trial limit reached</h1>
|
||||
<p className="text-center pb-2">
|
||||
To keep using Continue, please enter an API key or set up a local
|
||||
model
|
||||
</p>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<h1 className="text-center">Welcome to Continue</h1>
|
||||
<p className="text-center pb-2">
|
||||
Let's find the setup that works best for you
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
|
||||
<Div
|
||||
color={"#be841b"}
|
||||
disabled={false}
|
||||
|
|
@ -32,22 +54,22 @@ function Onboarding() {
|
|||
onMouseEnter={() => setHovered0(true)}
|
||||
onMouseLeave={() => setHovered0(false)}
|
||||
>
|
||||
<h3>✨ Cloud models</h3>
|
||||
<h3>✨ Use your API key</h3>
|
||||
<p>
|
||||
This is the best experience. Continue will use the strongest available
|
||||
commercial models to index code and answer questions. Code is only
|
||||
ever stored locally.
|
||||
Enter an OpenAI or other API key for the best experience. Continue
|
||||
will use the best available commercial models to index code. Code is
|
||||
only ever stored locally.
|
||||
</p>
|
||||
</Div>
|
||||
{selected === 0 && (
|
||||
<p className="px-3">
|
||||
<b>Chat:</b> Whichever model you choose
|
||||
<br />
|
||||
<br />
|
||||
<b>Embeddings:</b> Voyage Code 2
|
||||
<br />
|
||||
<br />
|
||||
<b>Autocomplete:</b> Starcoder 7b via Fireworks AI (free trial)
|
||||
<br />
|
||||
<br />
|
||||
<b>Chat:</b> GPT-4, Claude 3, and others (free trial)
|
||||
<b>Autocomplete:</b> Starcoder 7B via Fireworks AI
|
||||
</p>
|
||||
)}
|
||||
<br></br>
|
||||
|
|
@ -70,60 +92,16 @@ function Onboarding() {
|
|||
</Div>
|
||||
{selected === 1 && (
|
||||
<p className="px-3">
|
||||
<b>Embeddings:</b> Local sentence-transformers model
|
||||
<br />
|
||||
<br />
|
||||
<b>Autocomplete:</b> Starcoder2 3b (set up with Ollama, LM Studio,
|
||||
etc.)
|
||||
<br />
|
||||
<br />
|
||||
<b>Chat:</b> Llama 3 with Ollama, LM Studio, etc.
|
||||
<br />
|
||||
<br />
|
||||
<b>Embeddings:</b> Nomic Embed
|
||||
<br />
|
||||
<br />
|
||||
<b>Autocomplete:</b> Starcoder2 3B
|
||||
</p>
|
||||
)}
|
||||
<br></br>
|
||||
{/* <p>
|
||||
<a href="https://docs.continue.dev/customization/overview">
|
||||
Read the docs
|
||||
</a>{" "}
|
||||
to learn more and fully customize Continue by opening config.json.
|
||||
</p> */}
|
||||
<Div
|
||||
color={"#1b84be"}
|
||||
disabled={false}
|
||||
selected={selected === 2}
|
||||
hovered={hovered2}
|
||||
onMouseEnter={() => setHovered2(true)}
|
||||
onMouseLeave={() => setHovered2(false)}
|
||||
onClick={() => {
|
||||
setSelected(2);
|
||||
ideMessenger.post("openConfigJson", undefined);
|
||||
}}
|
||||
>
|
||||
<h3>⚙️ Your own models</h3>
|
||||
<p>
|
||||
Continue lets you use your own API key or self-hosted LLMs.{" "}
|
||||
<a href="https://docs.continue.dev/customization/overview">
|
||||
Read the docs
|
||||
</a>{" "}
|
||||
to learn more about using config.json to customize Continue. This can
|
||||
always be done later.
|
||||
</p>
|
||||
</Div>
|
||||
{selected === 2 && (
|
||||
<p className="px-3">
|
||||
Use <code>config.json</code> to configure your own{" "}
|
||||
<a href="https://docs.continue.dev/model-setup/overview">models</a>,{" "}
|
||||
<a href="https://docs.continue.dev/customization/context-providers">
|
||||
context providers
|
||||
</a>
|
||||
,{" "}
|
||||
<a href="https://docs.continue.dev/customization/slash-commands">
|
||||
slash commands
|
||||
</a>
|
||||
, and <a href="https://docs.continue.dev/reference/config">more</a>.
|
||||
</p>
|
||||
)}
|
||||
|
||||
<br />
|
||||
<div className="flex">
|
||||
<StyledButton
|
||||
|
|
@ -131,13 +109,13 @@ function Onboarding() {
|
|||
selected === 0
|
||||
? "#be841b"
|
||||
: selected === 1
|
||||
? greenButtonColor
|
||||
: "#1b84be"
|
||||
? greenButtonColor
|
||||
: "#1b84be"
|
||||
}
|
||||
disabled={selected < 0}
|
||||
onClick={() => {
|
||||
ideMessenger.post("completeOnboarding", {
|
||||
mode: ["optimized", "local", "custom"][selected] as any,
|
||||
mode: ["apiKeys", "local"][selected] as any,
|
||||
});
|
||||
setLocalStorage("onboardingComplete", true);
|
||||
|
||||
|
|
@ -146,15 +124,97 @@ function Onboarding() {
|
|||
} else {
|
||||
// Only needed when we switch from the default (local) embeddings provider
|
||||
ideMessenger.post("index/forceReIndex", undefined);
|
||||
// Don't show the tutorial above yet because there's another step to complete at /localOnboarding
|
||||
ideMessenger.post("showTutorial", undefined);
|
||||
navigate("/");
|
||||
navigate("/apiKeyOnboarding");
|
||||
}
|
||||
}}
|
||||
>
|
||||
Continue
|
||||
</StyledButton>
|
||||
</div>
|
||||
|
||||
{getLocalStorage("onboardingComplete") || (
|
||||
<>
|
||||
<hr className="w-full my-12"></hr>
|
||||
|
||||
<p className="text-center">
|
||||
OR sign in with GitHub to try 25 free requests
|
||||
</p>
|
||||
{isJetBrains() ? (
|
||||
<div className="text-center">
|
||||
<div className="flex justify-center">
|
||||
<SecondaryButton
|
||||
onClick={() => {
|
||||
ideMessenger.post(
|
||||
"openUrl",
|
||||
"https://github.com/settings/tokens/new?scopes=user:email&description=Continue%20Free%20Trial%20Token%20",
|
||||
);
|
||||
}}
|
||||
className="grid grid-flow-col items-center gap-2"
|
||||
>
|
||||
<svg
|
||||
viewBox="0 0 98 96"
|
||||
height={24}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
clip-rule="evenodd"
|
||||
d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"
|
||||
fill={vscForeground}
|
||||
/>
|
||||
</svg>
|
||||
Generate Token
|
||||
</SecondaryButton>
|
||||
</div>
|
||||
<Input
|
||||
placeholder="Paste token here"
|
||||
value={jbGhAuthToken}
|
||||
onChange={(e) => setJbGhAuthToken(e.target.value)}
|
||||
/>
|
||||
<Button
|
||||
disabled={!jbGhAuthToken}
|
||||
onClick={async () => {
|
||||
await ideMessenger.request("setGitHubAuthToken", {
|
||||
token: jbGhAuthToken,
|
||||
});
|
||||
setLocalStorage("onboardingComplete", true);
|
||||
navigate("/");
|
||||
}}
|
||||
>
|
||||
Continue
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex justify-center">
|
||||
<SecondaryButton
|
||||
onClick={async () => {
|
||||
await ideMessenger.request("getGitHubAuthToken", undefined);
|
||||
setLocalStorage("onboardingComplete", true);
|
||||
await ideMessenger.request("completeOnboarding", {
|
||||
mode: "freeTrial",
|
||||
});
|
||||
navigate("/");
|
||||
}}
|
||||
className="grid grid-flow-col items-center gap-2"
|
||||
>
|
||||
<svg
|
||||
viewBox="0 0 98 96"
|
||||
height={24}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
clip-rule="evenodd"
|
||||
d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"
|
||||
fill={vscForeground}
|
||||
/>
|
||||
</svg>
|
||||
Sign in with GitHub
|
||||
</SecondaryButton>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue