From 07d65112fe099e197c34cca8b93d9dbcf57ce786 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Fri, 19 Jul 2024 15:47:30 -0700 Subject: [PATCH 01/11] IAnalyticsProvider --- core/control-plane/TeamAnalytics.ts | 46 +++++++++---------- .../analytics/ElasticAnalyticsProvider.ts | 17 +++++++ .../analytics/IAnalyticsProvider.ts | 11 +++++ .../analytics/PostHogAnalyticsProvider.ts | 37 +++++++++++++++ core/package-lock.json | 8 ++-- core/package.json | 2 +- extensions/vscode/package-lock.json | 6 +-- gui/package-lock.json | 2 +- packages/config-types/package.json | 2 +- packages/config-types/src/index.ts | 9 ++++ 10 files changed, 107 insertions(+), 33 deletions(-) create mode 100644 core/control-plane/analytics/ElasticAnalyticsProvider.ts create mode 100644 core/control-plane/analytics/IAnalyticsProvider.ts create mode 100644 core/control-plane/analytics/PostHogAnalyticsProvider.ts diff --git a/core/control-plane/TeamAnalytics.ts b/core/control-plane/TeamAnalytics.ts index 96fafbbf7..bc529cecd 100644 --- a/core/control-plane/TeamAnalytics.ts +++ b/core/control-plane/TeamAnalytics.ts @@ -1,28 +1,33 @@ import { Analytics } from "@continuedev/config-types"; import os from "node:os"; +import { IAnalyticsProvider } from "./analytics/IAnalyticsProvider"; +import PostHogAnalyticsProvider from "./analytics/PostHogAnalyticsProvider"; + +function createAnalyticsProvider( + config: Analytics, +): IAnalyticsProvider | undefined { + switch (config.provider) { + case "posthog": + return new PostHogAnalyticsProvider(); + default: + return undefined; + } +} export class TeamAnalytics { - static client: any = undefined; + static provider: IAnalyticsProvider | undefined = undefined; static uniqueId = "NOT_UNIQUE"; static os: string | undefined = undefined; static extensionVersion: string | undefined = undefined; static async capture(event: string, properties: { [key: string]: any }) { - TeamAnalytics.client?.capture({ - distinctId: TeamAnalytics.uniqueId, - event, - properties: { - ...properties, - os: TeamAnalytics.os, - extensionVersion: TeamAnalytics.extensionVersion, - }, + TeamAnalytics.provider?.capture(event, { + ...properties, + os: TeamAnalytics.os, + extensionVersion: TeamAnalytics.extensionVersion, }); } - static shutdownPosthogClient() { - TeamAnalytics.client?.shutdown(); - } - static async setup( config: Analytics, uniqueId: string, @@ -32,17 +37,12 @@ export class TeamAnalytics { TeamAnalytics.os = os.platform(); TeamAnalytics.extensionVersion = extensionVersion; - if (!config || !config.clientKey || !config.url) { - TeamAnalytics.client = undefined; + if (!config) { + await TeamAnalytics.provider?.shutdown(); + TeamAnalytics.provider = undefined; } else { - try { - const { PostHog } = await import("posthog-node"); - TeamAnalytics.client = new PostHog(config.clientKey, { - host: config.url, - }); - } catch (e) { - console.error(`Failed to setup telemetry: ${e}`); - } + TeamAnalytics.provider = createAnalyticsProvider(config); + await TeamAnalytics.provider?.setup(config, uniqueId); } } } diff --git a/core/control-plane/analytics/ElasticAnalyticsProvider.ts b/core/control-plane/analytics/ElasticAnalyticsProvider.ts new file mode 100644 index 000000000..447b51740 --- /dev/null +++ b/core/control-plane/analytics/ElasticAnalyticsProvider.ts @@ -0,0 +1,17 @@ +import { Analytics } from "@continuedev/config-types"; +import { IAnalyticsProvider } from "./IAnalyticsProvider"; + +export default class ElasticAnalyticsProvider implements IAnalyticsProvider { + async capture( + event: string, + properties: { [key: string]: any }, + ): Promise { + throw new Error("Method not implemented."); + } + + async setup(config: Analytics, uniqueId: string): Promise { + throw new Error("Method not implemented."); + } + + async shutdown(): Promise {} +} diff --git a/core/control-plane/analytics/IAnalyticsProvider.ts b/core/control-plane/analytics/IAnalyticsProvider.ts new file mode 100644 index 000000000..8a04ba1ce --- /dev/null +++ b/core/control-plane/analytics/IAnalyticsProvider.ts @@ -0,0 +1,11 @@ +import { Analytics } from "@continuedev/config-types"; + +export interface AnalyticsMetadata { + extensionVersion: string; +} + +export interface IAnalyticsProvider { + capture(event: string, properties: { [key: string]: any }): Promise; + setup(config: Analytics, uniqueId: string): Promise; + shutdown(): Promise; +} diff --git a/core/control-plane/analytics/PostHogAnalyticsProvider.ts b/core/control-plane/analytics/PostHogAnalyticsProvider.ts new file mode 100644 index 000000000..f32a0737b --- /dev/null +++ b/core/control-plane/analytics/PostHogAnalyticsProvider.ts @@ -0,0 +1,37 @@ +import { Analytics } from "@continuedev/config-types"; +import { IAnalyticsProvider } from "./IAnalyticsProvider"; + +export default class PostHogAnalyticsProvider implements IAnalyticsProvider { + client?: any; + uniqueId?: string; + + async capture( + event: string, + properties: { [key: string]: any }, + ): Promise { + this.client?.capture({ + distinctId: this.uniqueId, + event, + properties, + }); + } + + async setup(config: Analytics, uniqueId: string): Promise { + if (!config || !config.clientKey || !config.url) { + this.client = undefined; + } else { + try { + this.uniqueId = uniqueId; + + const { PostHog } = await import("posthog-node"); + this.client = new PostHog(config.clientKey, { + host: config.url, + }); + } catch (e) { + console.error(`Failed to setup telemetry: ${e}`); + } + } + } + + async shutdown(): Promise {} +} diff --git a/core/package-lock.json b/core/package-lock.json index e52c1435e..e25eed033 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@aws-sdk/client-bedrock-runtime": "^3.574.0", "@aws-sdk/credential-providers": "^3.596.0", - "@continuedev/config-types": "^1.0.6", + "@continuedev/config-types": "^1.0.8", "@continuedev/llm-info": "^1.0.1", "@mozilla/readability": "^0.5.0", "@octokit/rest": "^20.0.2", @@ -3932,9 +3932,9 @@ } }, "node_modules/@continuedev/config-types": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.6.tgz", - "integrity": "sha512-JTlaGtsNW9vfSPcDJBn+I2vcs0wWRFIQcN3sa6pBFg2fj8W6qcMZoYUdzoU/+X+2ZT8OKcbomWfP2+qW0uuy6A==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.8.tgz", + "integrity": "sha512-AwrqMK+FSVY1vFaEujVbOI2ETAYmRv6dT9qs/FYhKNCUNIVDbeI0/Mhf6APBVfgK8czrB6XVbY1aJFiZHGqejw==", "dependencies": { "zod": "^3.23.8" } diff --git a/core/package.json b/core/package.json index 16c88a868..fafef2f4c 100644 --- a/core/package.json +++ b/core/package.json @@ -32,7 +32,7 @@ "dependencies": { "@aws-sdk/client-bedrock-runtime": "^3.574.0", "@aws-sdk/credential-providers": "^3.596.0", - "@continuedev/config-types": "^1.0.6", + "@continuedev/config-types": "^1.0.8", "@continuedev/llm-info": "^1.0.1", "@mozilla/readability": "^0.5.0", "@octokit/rest": "^20.0.2", diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index c1382a701..0903bae7e 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.185", + "version": "0.9.186", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.185", + "version": "0.9.186", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", @@ -97,7 +97,7 @@ "dependencies": { "@aws-sdk/client-bedrock-runtime": "^3.574.0", "@aws-sdk/credential-providers": "^3.596.0", - "@continuedev/config-types": "^1.0.6", + "@continuedev/config-types": "^1.0.8", "@continuedev/llm-info": "^1.0.1", "@mozilla/readability": "^0.5.0", "@octokit/rest": "^20.0.2", diff --git a/gui/package-lock.json b/gui/package-lock.json index 47df1bfbb..3dd209c43 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -90,7 +90,7 @@ "dependencies": { "@aws-sdk/client-bedrock-runtime": "^3.574.0", "@aws-sdk/credential-providers": "^3.596.0", - "@continuedev/config-types": "^1.0.6", + "@continuedev/config-types": "^1.0.8", "@continuedev/llm-info": "^1.0.1", "@mozilla/readability": "^0.5.0", "@octokit/rest": "^20.0.2", diff --git a/packages/config-types/package.json b/packages/config-types/package.json index 091f18cd0..4a4d269e0 100644 --- a/packages/config-types/package.json +++ b/packages/config-types/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/config-types", - "version": "1.0.7", + "version": "1.0.8", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/config-types/src/index.ts b/packages/config-types/src/index.ts index e96f1696b..8d0a1b588 100644 --- a/packages/config-types/src/index.ts +++ b/packages/config-types/src/index.ts @@ -176,6 +176,15 @@ export const rerankerSchema = z.object({ export type Reranker = z.infer; export const analyticsSchema = z.object({ + provider: z.enum([ + "posthog", + "amplitude", + "segment", + "elastic", + "mixpanel", + "splunk", + "datadog", + ]), url: z.string().optional(), clientKey: z.string().optional(), }); From a894dd80eacb94584380ce7a7a76d26b8f176b45 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Fri, 19 Jul 2024 16:37:01 -0700 Subject: [PATCH 02/11] update workspaces on session info change --- core/config/ConfigHandler.ts | 82 +++++++------ core/core.ts | 21 +++- .../vscode/src/extension/VsCodeExtension.ts | 5 +- gui/src/components/ProfileSwitcher.tsx | 108 +++++++++--------- 4 files changed, 124 insertions(+), 92 deletions(-) diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index e01b41e0e..64669f68d 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -1,4 +1,7 @@ -import { ControlPlaneClient } from "../control-plane/client.js"; +import { + ControlPlaneClient, + ControlPlaneSessionInfo, +} from "../control-plane/client.js"; import { BrowserSerializedContinueConfig, ContinueConfig, @@ -118,44 +121,20 @@ export class ConfigHandler { return this.profiles.filter((p) => p.profileId !== this.selectedProfileId); } - constructor( - private readonly ide: IDE, - private ideSettingsPromise: Promise, - private readonly writeLog: (text: string) => Promise, - private readonly controlPlaneClient: ControlPlaneClient, - ) { - this.ide = ide; - this.ideSettingsPromise = ideSettingsPromise; - this.writeLog = writeLog; - - // Set local profile as default - const localProfileLoader = new LocalProfileLoader( - ide, - ideSettingsPromise, - writeLog, - ); - this.profiles = [new ProfileLifecycleManager(localProfileLoader)]; - this.selectedProfileId = localProfileLoader.profileId; - - // Always load local profile immediately in case control plane doesn't load - try { - this.loadConfig(); - } catch (e) { - console.error("Failed to load config: ", e); - } - - // Load control plane profiles - // TODO + private async fetchControlPlaneProfiles() { // Get the profiles and create their lifecycle managers this.controlPlaneClient.listWorkspaces().then(async (workspaces) => { + this.profiles = this.profiles.filter( + (profile) => profile.profileId === "local", + ); workspaces.forEach((workspace) => { const profileLoader = new ControlPlaneProfileLoader( workspace.id, workspace.name, this.controlPlaneClient, - ide, - ideSettingsPromise, - writeLog, + this.ide, + this.ideSettingsPromise, + this.writeLog, this.reloadConfig.bind(this), ); this.profiles.push(new ProfileLifecycleManager(profileLoader)); @@ -184,6 +163,36 @@ export class ConfigHandler { }); } + constructor( + private readonly ide: IDE, + private ideSettingsPromise: Promise, + private readonly writeLog: (text: string) => Promise, + private controlPlaneClient: ControlPlaneClient, + ) { + this.ide = ide; + this.ideSettingsPromise = ideSettingsPromise; + this.writeLog = writeLog; + + // Set local profile as default + const localProfileLoader = new LocalProfileLoader( + ide, + ideSettingsPromise, + writeLog, + ); + this.profiles = [new ProfileLifecycleManager(localProfileLoader)]; + this.selectedProfileId = localProfileLoader.profileId; + + // Always load local profile immediately in case control plane doesn't load + try { + this.loadConfig(); + } catch (e) { + console.error("Failed to load config: ", e); + } + + // Load control plane profiles + this.fetchControlPlaneProfiles(); + } + async setSelectedProfile(profileId: string) { this.selectedProfileId = profileId; const newConfig = await this.loadConfig(); @@ -209,6 +218,15 @@ export class ConfigHandler { this.reloadConfig(); } + updateControlPlaneSessionInfo( + sessionInfo: ControlPlaneSessionInfo | undefined, + ) { + this.controlPlaneClient = new ControlPlaneClient( + Promise.resolve(sessionInfo), + ); + this.fetchControlPlaneProfiles(); + } + private profilesListeners: ((profiles: ProfileDescription[]) => void)[] = []; onDidChangeAvailableProfiles( listener: (profiles: ProfileDescription[]) => void, diff --git a/core/core.ts b/core/core.ts index 25e44a849..3244ae9ef 100644 --- a/core/core.ts +++ b/core/core.ts @@ -248,9 +248,9 @@ export class Core { (provider) => provider.description.title === "docs", ); - const siteIndexingOptions: SiteIndexingConfig[] = provider ? - (mProvider => mProvider?.options?.sites || [])({ ...provider }) : - []; + const siteIndexingOptions: SiteIndexingConfig[] = provider + ? ((mProvider) => mProvider?.options?.sites || [])({ ...provider }) + : []; await this.indexDocs(siteIndexingOptions, msg.data.reIndex); this.ide.infoPopup("Docs indexing completed"); @@ -619,6 +619,9 @@ export class Core { on("didChangeSelectedProfile", (msg) => { this.configHandler.setSelectedProfile(msg.data.id); }); + on("didChangeControlPlaneSessionInfo", async (msg) => { + this.configHandler.updateControlPlaneSessionInfo(msg.data.sessionInfo); + }); } private indexingCancellationController: AbortController | undefined; @@ -637,12 +640,18 @@ export class Core { } } - private async indexDocs(sites: SiteIndexingConfig[], reIndex: boolean): Promise { + private async indexDocs( + sites: SiteIndexingConfig[], + reIndex: boolean, + ): Promise { for (const site of sites) { - for await (const update of this.docsService.indexAndAdd(site, new TransformersJsEmbeddingsProvider(), reIndex)) { + for await (const update of this.docsService.indexAndAdd( + site, + new TransformersJsEmbeddingsProvider(), + reIndex, + )) { // Temporary disabled posting progress updates to the UI due to // possible collision with code indexing progress updates. - // this.messenger.request("indexProgress", update); // this.indexingState = update; } diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts index d0b406a8a..a4db8ed6d 100644 --- a/extensions/vscode/src/extension/VsCodeExtension.ts +++ b/extensions/vscode/src/extension/VsCodeExtension.ts @@ -257,12 +257,12 @@ export class VsCodeExtension { }); // When GitHub sign-in status changes, reload config - vscode.authentication.onDidChangeSessions((e) => { + vscode.authentication.onDidChangeSessions(async (e) => { if (e.provider.id === "github") { this.configHandler.reloadConfig(); } else if (e.provider.id === "continue") { + const sessionInfo = await getControlPlaneSessionInfo(true); this.webviewProtocolPromise.then(async (webviewProtocol) => { - const sessionInfo = await getControlPlaneSessionInfo(true); webviewProtocol.request("didChangeControlPlaneSessionInfo", { sessionInfo, }); @@ -270,6 +270,7 @@ export class VsCodeExtension { // To make sure continue-proxy models and anything else requiring it get updated access token this.configHandler.reloadConfig(); }); + this.core.invoke("didChangeControlPlaneSessionInfo", { sessionInfo }); } }); diff --git a/gui/src/components/ProfileSwitcher.tsx b/gui/src/components/ProfileSwitcher.tsx index e1545ba5a..24fc99b31 100644 --- a/gui/src/components/ProfileSwitcher.tsx +++ b/gui/src/components/ProfileSwitcher.tsx @@ -160,58 +160,62 @@ function ProfileSwitcher(props: {}) { return ( <> - {controlServerBetaEnabled && profiles.length > 0 && ( - { - ideMessenger.request("didChangeSelectedProfile", { id }); - }} - > -
- -
{selectedProfile()?.title}
-
-
-
- {topDiv && - ReactDOM.createPortal( - - - {profiles.map((option, idx) => ( - 1} - /> - ))} -
- {profiles.length === 0 ? ( - No profiles found - ) : ( - "Select profile" - )} -
-
-
, - topDiv, - )} -
-
- )} + {controlServerBetaEnabled && + profiles.some((profile) => profile.id !== "local") && ( + { + ideMessenger.request("didChangeSelectedProfile", { id }); + }} + > +
+ +
{selectedProfile()?.title}
+
+
+
+ {topDiv && + ReactDOM.createPortal( + + + {profiles.map((option, idx) => ( + 1} + /> + ))} +
+ {profiles.length === 0 ? ( + No profiles found + ) : ( + "Select profile" + )} +
+
+
, + topDiv, + )} +
+
+ )} {/* Settings button (either opens config.json or /settings page in control plane) */} Date: Fri, 19 Jul 2024 16:39:01 -0700 Subject: [PATCH 03/11] rename from profile to workspace (user-facing) --- gui/src/components/ProfileSwitcher.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/src/components/ProfileSwitcher.tsx b/gui/src/components/ProfileSwitcher.tsx index 24fc99b31..4733fc195 100644 --- a/gui/src/components/ProfileSwitcher.tsx +++ b/gui/src/components/ProfileSwitcher.tsx @@ -204,9 +204,9 @@ function ProfileSwitcher(props: {}) { }} > {profiles.length === 0 ? ( - No profiles found + No workspaces found ) : ( - "Select profile" + "Select workspace" )} From 27772b9f2bc06770b7c0cb288e3afd0945afc1fe Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sat, 20 Jul 2024 10:39:42 -0700 Subject: [PATCH 04/11] update config schema files --- docs/static/schemas/config.json | 50 ++++++++++++++++++- .../src/main/resources/config_schema.json | 50 ++++++++++++++++++- extensions/vscode/continue_rc_schema.json | 49 ++++++++++++++++++ 3 files changed, 145 insertions(+), 4 deletions(-) diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index 19813eb6a..ac7461d8f 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -1395,6 +1395,46 @@ } }, "allOf": [ + { + "if": { + "properties": { + "name": { + "enum": ["docs"] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "sites": { + "type": "array", + "items": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "startUrl": { + "type": "string" + }, + "rootUrl": { + "type": "string" + }, + "maxDepth": { + "type": "integer" + } + }, + "required": ["title", "startUrl"] + } + } + }, + "required": ["sites"] + } + }, + "required": ["params"] + } + }, { "if": { "properties": { @@ -1955,7 +1995,13 @@ "type": "object", "properties": { "name": { - "enum": ["cohere", "voyage", "llm", "free-trial", "huggingface-tei"] + "enum": [ + "cohere", + "voyage", + "llm", + "free-trial", + "huggingface-tei" + ] }, "params": { "type": "object" @@ -2070,7 +2116,7 @@ "default": false }, "truncation_direction": { - "enum": ["Right","Left"], + "enum": ["Right", "Left"], "markdownDescription": "Wether to truncate sequences from the `left` or `right`.", "default": "Right" } diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 19813eb6a..ac7461d8f 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -1395,6 +1395,46 @@ } }, "allOf": [ + { + "if": { + "properties": { + "name": { + "enum": ["docs"] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "sites": { + "type": "array", + "items": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "startUrl": { + "type": "string" + }, + "rootUrl": { + "type": "string" + }, + "maxDepth": { + "type": "integer" + } + }, + "required": ["title", "startUrl"] + } + } + }, + "required": ["sites"] + } + }, + "required": ["params"] + } + }, { "if": { "properties": { @@ -1955,7 +1995,13 @@ "type": "object", "properties": { "name": { - "enum": ["cohere", "voyage", "llm", "free-trial", "huggingface-tei"] + "enum": [ + "cohere", + "voyage", + "llm", + "free-trial", + "huggingface-tei" + ] }, "params": { "type": "object" @@ -2070,7 +2116,7 @@ "default": false }, "truncation_direction": { - "enum": ["Right","Left"], + "enum": ["Right", "Left"], "markdownDescription": "Wether to truncate sequences from the `left` or `right`.", "default": "Right" } diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index e1da75f39..2c67ce0c1 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -1541,6 +1541,55 @@ } }, "allOf": [ + { + "if": { + "properties": { + "name": { + "enum": [ + "docs" + ] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "sites": { + "type": "array", + "items": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "startUrl": { + "type": "string" + }, + "rootUrl": { + "type": "string" + }, + "maxDepth": { + "type": "integer" + } + }, + "required": [ + "title", + "startUrl" + ] + } + } + }, + "required": [ + "sites" + ] + } + }, + "required": [ + "params" + ] + } + }, { "if": { "properties": { From 8d83472792bf41ac7207f8a09514c8d3e82d5657 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Mon, 22 Jul 2024 11:08:11 -0700 Subject: [PATCH 05/11] add "language" template variable for autocomplete --- core/autocomplete/completionProvider.ts | 1 + core/autocomplete/languages.ts | 24 ++++++++++++++++++++++++ eval/repos/amplified-dev | 1 - eval/repos/continue | 1 - eval/repos/the-x | 1 - eval/repos/trayracer | 1 - 6 files changed, 25 insertions(+), 4 deletions(-) delete mode 160000 eval/repos/amplified-dev delete mode 160000 eval/repos/continue delete mode 160000 eval/repos/the-x delete mode 160000 eval/repos/trayracer diff --git a/core/autocomplete/completionProvider.ts b/core/autocomplete/completionProvider.ts index 418a81131..1cd43bf4f 100644 --- a/core/autocomplete/completionProvider.ts +++ b/core/autocomplete/completionProvider.ts @@ -581,6 +581,7 @@ export class CompletionProvider { suffix, filename, reponame, + language: lang.name, }); } else { // Let the template function format snippets diff --git a/core/autocomplete/languages.ts b/core/autocomplete/languages.ts index 3360c3a9b..a558dee00 100644 --- a/core/autocomplete/languages.ts +++ b/core/autocomplete/languages.ts @@ -1,6 +1,7 @@ import type { LineFilter } from "./lineStream"; export interface AutocompleteLanguageInfo { + name: string; topLevelKeywords: string[]; singleLineComment: string; endOfLine: string[]; @@ -14,6 +15,7 @@ export interface AutocompleteLanguageInfo { // TypeScript export const Typescript = { + name: "TypeScript", topLevelKeywords: ["function", "class", "module", "export", "import"], singleLineComment: "//", endOfLine: [";"], @@ -21,6 +23,7 @@ export const Typescript = { // Python export const Python = { + name: "Python", // """"#" is for .ipynb files, where we add '"""' surrounding markdown blocks. // This stops the model from trying to complete the start of a new markdown block topLevelKeywords: ["def", "class", '"""#'], @@ -30,6 +33,7 @@ export const Python = { // Java export const Java = { + name: "Java", topLevelKeywords: ["class", "function"], singleLineComment: "//", endOfLine: [";"], @@ -37,6 +41,7 @@ export const Java = { // C++ export const Cpp = { + name: "C++", topLevelKeywords: ["class", "namespace", "template"], singleLineComment: "//", endOfLine: [";"], @@ -44,6 +49,7 @@ export const Cpp = { // C# export const CSharp = { + name: "C#", topLevelKeywords: ["class", "namespace", "void"], singleLineComment: "//", endOfLine: [";"], @@ -51,6 +57,7 @@ export const CSharp = { // C export const C = { + name: "C", topLevelKeywords: ["if", "else", "while", "for", "switch", "case"], singleLineComment: "//", endOfLine: [";"], @@ -58,6 +65,7 @@ export const C = { // Scala export const Scala = { + name: "Scala", topLevelKeywords: ["def", "val", "var", "class", "object", "trait"], singleLineComment: "//", endOfLine: [";"], @@ -65,6 +73,7 @@ export const Scala = { // Go export const Go = { + name: "Go", topLevelKeywords: ["func", "package", "import", "type"], singleLineComment: "//", endOfLine: [], @@ -72,6 +81,7 @@ export const Go = { // Rust export const Rust = { + name: "Rust", topLevelKeywords: ["fn", "mod", "pub", "struct", "enum", "trait"], singleLineComment: "//", endOfLine: [";"], @@ -79,6 +89,7 @@ export const Rust = { // Haskell export const Haskell = { + name: "Haskell", topLevelKeywords: [ "data", "type", @@ -95,6 +106,7 @@ export const Haskell = { // PHP export const PHP = { + name: "PHP", topLevelKeywords: ["function", "class", "namespace", "use"], singleLineComment: "//", endOfLine: [";"], @@ -102,6 +114,7 @@ export const PHP = { // Ruby on Rails export const RubyOnRails = { + name: "Ruby on Rails", topLevelKeywords: ["def", "class", "module"], singleLineComment: "#", endOfLine: [], @@ -109,6 +122,7 @@ export const RubyOnRails = { // Swift export const Swift = { + name: "Swift", topLevelKeywords: ["func", "class", "struct", "import"], singleLineComment: "//", endOfLine: [";"], @@ -116,6 +130,7 @@ export const Swift = { // Kotlin export const Kotlin = { + name: "Kotlin", topLevelKeywords: ["fun", "class", "package", "import"], singleLineComment: "//", endOfLine: [";"], @@ -123,6 +138,7 @@ export const Kotlin = { // Ruby export const Ruby = { + name: "Ruby", topLevelKeywords: ["class", "module", "def"], singleLineComment: "#", endOfLine: [], @@ -130,6 +146,7 @@ export const Ruby = { // Clojure export const Clojure = { + name: "Clojure", topLevelKeywords: ["def", "fn", "let", "do", "if", "defn", "ns", "defmacro"], singleLineComment: ";", endOfLine: [], @@ -137,6 +154,7 @@ export const Clojure = { // Julia export const Julia = { + name: "Julia", topLevelKeywords: [ "function", "macro", @@ -155,6 +173,7 @@ export const Julia = { // F# export const FSharp = { + name: "F#", topLevelKeywords: [ "let", "type", @@ -173,6 +192,7 @@ export const FSharp = { // R export const R = { + name: "R", topLevelKeywords: [ "function", "if", @@ -189,6 +209,7 @@ export const R = { // Dart export const Dart = { + name: "Dart", topLevelKeywords: ["class", "import", "void", "enum"], singleLineComment: "//", endOfLine: [";"], @@ -196,6 +217,7 @@ export const Dart = { // Solidity export const Solidity = { + name: "Solidity", topLevelKeywords: [ "contract", "event", @@ -218,6 +240,7 @@ export const Solidity = { // YAML export const YAML: AutocompleteLanguageInfo = { + name: "YAML", topLevelKeywords: [], singleLineComment: "#", endOfLine: [], @@ -258,6 +281,7 @@ export const YAML: AutocompleteLanguageInfo = { }; export const Markdown: AutocompleteLanguageInfo = { + name: "Markdown", topLevelKeywords: [], singleLineComment: "", endOfLine: [], diff --git a/eval/repos/amplified-dev b/eval/repos/amplified-dev deleted file mode 160000 index 4cf94d702..000000000 --- a/eval/repos/amplified-dev +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4cf94d7023f5063f912d376027194fbd67670ba5 diff --git a/eval/repos/continue b/eval/repos/continue deleted file mode 160000 index 2eafdff54..000000000 --- a/eval/repos/continue +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2eafdff54b1a77c6d403fa26a64c6793d7a4dfb9 diff --git a/eval/repos/the-x b/eval/repos/the-x deleted file mode 160000 index 9218fea44..000000000 --- a/eval/repos/the-x +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9218fea4483ffcbbdf1471c83f65c01f3c25f554 diff --git a/eval/repos/trayracer b/eval/repos/trayracer deleted file mode 160000 index 2f0e7fbe9..000000000 --- a/eval/repos/trayracer +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2f0e7fbe962312a1b8bef8a29ed1ac4111ab11c4 From 570afb8efc7ee99bd6d12ea6ec6ba58373a5fcbd Mon Sep 17 00:00:00 2001 From: Josh Vera Date: Mon, 22 Jul 2024 15:50:37 -0400 Subject: [PATCH 06/11] Enable debug logs (#1800) * Add an enableDebugLogs flag * Send logs to VSCode --- core/index.d.ts | 1 + core/util/filesystem.ts | 1 + extensions/vscode/package.json | 5 + .../src/ContinueGUIWebviewViewProvider.ts | 67 +++++++++ extensions/vscode/src/ideProtocol.ts | 1 + gui/src/hooks/useSubmenuContextProviders.tsx | 141 +++++++++++------- 6 files changed, 160 insertions(+), 56 deletions(-) diff --git a/core/index.d.ts b/core/index.d.ts index 55969eed8..53205fe82 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -422,6 +422,7 @@ export interface IdeSettings { remoteConfigSyncPeriod: number; userToken: string; enableControlServerBeta: boolean; + enableDebugLogs: boolean } export interface IDE { diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index 7b849cb33..3f214bc69 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -38,6 +38,7 @@ class FileSystemIde implements IDE { remoteConfigSyncPeriod: 60, userToken: "", enableControlServerBeta: false, + enableDebugLogs: false, }; } async getGitHubAuthToken(): Promise { diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index b3423829c..ce591b2e4 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -94,6 +94,11 @@ "default": false, "markdownDescription": "Pause Continue's tab autocomplete feature when your battery is low." }, + "continue.enableDebugLogs": { + "type": "boolean", + "default": false, + "markdownDescription": "Enable Continue Debug Logs in the Output panel." + }, "continue.remoteConfigServerUrl": { "type": "string", "default": null, diff --git a/extensions/vscode/src/ContinueGUIWebviewViewProvider.ts b/extensions/vscode/src/ContinueGUIWebviewViewProvider.ts index c713244b0..08fedd54e 100644 --- a/extensions/vscode/src/ContinueGUIWebviewViewProvider.ts +++ b/extensions/vscode/src/ContinueGUIWebviewViewProvider.ts @@ -12,12 +12,55 @@ export class ContinueGUIWebviewViewProvider public static readonly viewType = "continue.continueGUIView"; public webviewProtocol: VsCodeWebviewProtocol; + private updateDebugLogsStatus() { + const settings = vscode.workspace.getConfiguration("continue"); + this.enableDebugLogs = settings.get("enableDebugLogs", false); + if (this.enableDebugLogs) { + this.outputChannel.show(true); + } else { + this.outputChannel.hide(); + } + } + + // Show or hide the output channel on enableDebugLogs + private setupDebugLogsListener() { + vscode.workspace.onDidChangeConfiguration((event) => { + if (event.affectsConfiguration('continue.enableDebugLogs')) { + const settings = vscode.workspace.getConfiguration("continue"); + const enableDebugLogs = settings.get("enableDebugLogs", false); + if (enableDebugLogs) { + this.outputChannel.show(true); + } else { + this.outputChannel.hide(); + } + } + }); + } + + private async handleWebviewMessage(message: any) { + if (message.messageType === "log") { + const settings = vscode.workspace.getConfiguration("continue"); + const enableDebugLogs = settings.get("enableDebugLogs", false); + + if (message.level === "debug" && !enableDebugLogs) { + return; // Skip debug logs if enableDebugLogs is false + } + + const timestamp = new Date().toISOString().split(".")[0]; + const logMessage = `[${timestamp}] [${message.level.toUpperCase()}] ${message.text}`; + this.outputChannel.appendLine(logMessage); + } +} + resolveWebviewView( webviewView: vscode.WebviewView, _context: vscode.WebviewViewResolveContext, _token: vscode.CancellationToken, ): void | Thenable { this._webview = webviewView.webview; + this._webview.onDidReceiveMessage((message) => + this.handleWebviewMessage(message), + ); webviewView.webview.html = this.getSidebarContent( this.extensionContext, webviewView, @@ -26,6 +69,8 @@ export class ContinueGUIWebviewViewProvider private _webview?: vscode.Webview; private _webviewView?: vscode.WebviewView; + private outputChannel: vscode.OutputChannel; + private enableDebugLogs: boolean; get isVisible() { return this._webviewView?.visible; @@ -50,11 +95,17 @@ export class ContinueGUIWebviewViewProvider }); } + constructor( private readonly configHandlerPromise: Promise, private readonly windowId: string, private readonly extensionContext: vscode.ExtensionContext, ) { + this.outputChannel = vscode.window.createOutputChannel("Continue"); + this.enableDebugLogs = false; + this.updateDebugLogsStatus(); + this.setupDebugLogsListener(); + this.webviewProtocol = new VsCodeWebviewProtocol( (async () => { const configHandler = await this.configHandlerPromise; @@ -131,6 +182,22 @@ export class ContinueGUIWebviewViewProvider
+ ${``} ${ inDevelopmentMode ? `