diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index ef5cd3ec2..80768ea4b 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -86,44 +86,49 @@ export class ConfigHandler { 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, - this.ide, - this.ideSettingsPromise, - this.writeLog, - this.reloadConfig.bind(this), + this.controlPlaneClient + .listWorkspaces() + .then(async (workspaces) => { + this.profiles = this.profiles.filter( + (profile) => profile.profileId === "local", ); - this.profiles.push(new ProfileLifecycleManager(profileLoader)); + workspaces.forEach((workspace) => { + const profileLoader = new ControlPlaneProfileLoader( + workspace.id, + workspace.name, + this.controlPlaneClient, + this.ide, + this.ideSettingsPromise, + this.writeLog, + this.reloadConfig.bind(this), + ); + this.profiles.push(new ProfileLifecycleManager(profileLoader)); + }); + + this.notifyProfileListeners( + this.profiles.map((profile) => profile.profileDescription), + ); + + // Check the last selected workspace, and reload if it isn't local + const workspaceId = await this.getWorkspaceId(); + const lastSelectedWorkspaceIds = + this.globalContext.get("lastSelectedProfileForWorkspace") ?? {}; + const selectedWorkspaceId = lastSelectedWorkspaceIds[workspaceId]; + if (selectedWorkspaceId) { + this.selectedProfileId = selectedWorkspaceId; + await this.loadConfig(); + } else { + // Otherwise we stick with local profile, and record choice + lastSelectedWorkspaceIds[workspaceId] = this.selectedProfileId; + this.globalContext.update( + "lastSelectedProfileForWorkspace", + lastSelectedWorkspaceIds, + ); + } + }) + .catch((e) => { + console.error(e); }); - - this.notifyProfileListeners( - this.profiles.map((profile) => profile.profileDescription), - ); - - // Check the last selected workspace, and reload if it isn't local - const workspaceId = await this.getWorkspaceId(); - const lastSelectedWorkspaceIds = - this.globalContext.get("lastSelectedProfileForWorkspace") ?? {}; - const selectedWorkspaceId = lastSelectedWorkspaceIds[workspaceId]; - if (selectedWorkspaceId) { - this.selectedProfileId = selectedWorkspaceId; - this.loadConfig(); - } else { - // Otherwise we stick with local profile, and record choice - lastSelectedWorkspaceIds[workspaceId] = this.selectedProfileId; - this.globalContext.update( - "lastSelectedProfileForWorkspace", - lastSelectedWorkspaceIds, - ); - } - }); } async setSelectedProfile(profileId: string) { diff --git a/core/llm/llms/stubs/ContinueProxy.ts b/core/llm/llms/stubs/ContinueProxy.ts index e91e92e06..0db131bed 100644 --- a/core/llm/llms/stubs/ContinueProxy.ts +++ b/core/llm/llms/stubs/ContinueProxy.ts @@ -1,5 +1,6 @@ import { ControlPlaneProxyInfo } from "../../../control-plane/analytics/IAnalyticsProvider.js"; import type { LLMOptions, ModelProvider } from "../../../index.js"; +import { Telemetry } from "../../../util/posthog.js"; import OpenAI from "../OpenAI.js"; class ContinueProxy extends OpenAI { @@ -11,6 +12,11 @@ class ContinueProxy extends OpenAI { static providerName: ModelProvider = "continue-proxy"; static defaultOptions: Partial = { useLegacyCompletionsEndpoint: false, + requestOptions: { + headers: { + "x-continue-unique-id": Telemetry.uniqueId, + }, + }, }; supportsCompletions(): boolean {