diff --git a/core/config/ProfileLifecycleManager.ts b/core/config/ProfileLifecycleManager.ts index 8216153ae..07c6a2c7d 100644 --- a/core/config/ProfileLifecycleManager.ts +++ b/core/config/ProfileLifecycleManager.ts @@ -23,6 +23,12 @@ export interface ProfileDescription { errors: ConfigValidationError[] | undefined; } +export interface OrganizationDescription { + id: string; + iconUrl: string; + name: string; +} + export class ProfileLifecycleManager { private savedConfigResult: ConfigResult | undefined; private savedBrowserConfigResult?: ConfigResult; diff --git a/core/config/profile/ControlPlaneProfileLoader.ts b/core/config/profile/ControlPlaneProfileLoader.ts index dfb111e1f..6df837cf4 100644 --- a/core/config/profile/ControlPlaneProfileLoader.ts +++ b/core/config/profile/ControlPlaneProfileLoader.ts @@ -1,4 +1,5 @@ import { ConfigJson } from "@continuedev/config-types"; +import { ConfigResult } from "@continuedev/config-yaml"; import { ControlPlaneClient } from "../../control-plane/client.js"; import { @@ -7,9 +8,8 @@ import { IdeSettings, SerializedContinueConfig, } from "../../index.js"; - -import { ConfigResult } from "@continuedev/config-yaml"; import { ProfileDescription } from "../ProfileLifecycleManager.js"; + import doLoadConfig from "./doLoadConfig.js"; import { IProfileLoader } from "./IProfileLoader.js"; @@ -32,6 +32,7 @@ export default class ControlPlaneProfileLoader implements IProfileLoader { this.description = { id: workspaceId, profileType: "control-plane", + iconUrl: "", fullSlug: { ownerSlug: "", packageSlug: "", diff --git a/core/config/profile/LocalProfileLoader.ts b/core/config/profile/LocalProfileLoader.ts index cb8694bbc..3196faff4 100644 --- a/core/config/profile/LocalProfileLoader.ts +++ b/core/config/profile/LocalProfileLoader.ts @@ -1,8 +1,9 @@ import { ConfigResult } from "@continuedev/config-yaml"; + import { ControlPlaneClient } from "../../control-plane/client.js"; import { ContinueConfig, IDE, IdeSettings } from "../../index.js"; - import { ProfileDescription } from "../ProfileLifecycleManager.js"; + import doLoadConfig from "./doLoadConfig.js"; import { IProfileLoader } from "./IProfileLoader.js"; @@ -16,6 +17,7 @@ export default class LocalProfileLoader implements IProfileLoader { packageSlug: "", versionSlug: "", }, + iconUrl: "", title: "Local Config", errors: undefined, }; diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index 6200bc8de..7c15c8910 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -1,8 +1,4 @@ import { ConfigJson } from "@continuedev/config-types"; -import fetch, { RequestInit, Response } from "node-fetch"; - -import { IdeSettings, ModelDescription } from "../index.js"; - import { AssistantUnrolled, ConfigResult, @@ -10,6 +6,11 @@ import { FullSlug, SecretResult, } from "@continuedev/config-yaml"; +import fetch, { RequestInit, Response } from "node-fetch"; + +import { OrganizationDescription } from "../config/ProfileLifecycleManager.js"; +import { IdeSettings, ModelDescription } from "../index.js"; + import { getControlPlaneEnv } from "./env.js"; export interface ControlPlaneSessionInfo { @@ -32,10 +33,6 @@ export const TRIAL_PROXY_URL = "https://proxy-server-blue-l6vsfbzhba-uw.a.run.app"; export class ControlPlaneClient { - private static ACCESS_TOKEN_VALID_FOR_MS = 1000 * 60 * 5; // 5 minutes - - private lastAccessTokenRefresh = 0; - constructor( private readonly sessionInfoPromise: Promise< ControlPlaneSessionInfo | undefined @@ -107,7 +104,7 @@ export class ControlPlaneClient { } } - public async listAssistants(): Promise< + public async listAssistants(organizationId?: string): Promise< { configResult: ConfigResult; ownerSlug: string; @@ -121,7 +118,11 @@ export class ControlPlaneClient { } try { - const resp = await this.request("ide/list-assistants", { + const url = organizationId + ? `ide/list-assistants?organizationId=${organizationId}` + : "ide/list-assistants"; + + const resp = await this.request(url, { method: "GET", }); return (await resp.json()) as any; @@ -130,6 +131,31 @@ export class ControlPlaneClient { } } + public async listOrganizations(): Promise> { + return [ + { + id: "1", + iconUrl: + "https://cdn.prod.website-files.com/663e06c56841363663ffbbcf/663e1b9fb023f0b622ad3608_log-text.svg", + name: "Continue", + }, + ]; + // const userId = await this.userId; + // if (!userId) { + // return []; + // } + + // try { + // const resp = await this.request("ide/list-organizations", { + // method: "GET", + // }); + // const { organizations } = (await resp.json()) as any; + // return organizations; + // } catch (e) { + // return []; + // } + } + public async listAssistantFullSlugs(): Promise { const userId = await this.userId; if (!userId) { diff --git a/core/core.ts b/core/core.ts index e5bff1f31..b55feafb2 100644 --- a/core/core.ts +++ b/core/core.ts @@ -307,6 +307,10 @@ export class Core { await this.messenger.request("openUrl", `${env.APP_URL}${msg.data.path}`); }); + on("controlPlane/listOrganizations", async (msg) => { + return await this.controlPlaneClient.listOrganizations(); + }); + // Context providers on("context/addDocs", async (msg) => { void this.docsService.indexAndAdd(msg.data); diff --git a/core/protocol/core.ts b/core/protocol/core.ts index ce24dfcbb..64bc5f5d4 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -1,4 +1,10 @@ import { ConfigResult } from "@continuedev/config-yaml"; + +import { AutocompleteInput } from "../autocomplete/util/types"; +import { ProfileDescription } from "../config/ConfigHandler"; +import { OrganizationDescription } from "../config/ProfileLifecycleManager"; +import { SharedConfigSchema } from "../config/sharedConfig"; + import type { BrowserSerializedContinueConfig, ChatMessage, @@ -21,9 +27,6 @@ import type { SiteIndexingConfig, ToolCall, } from "../"; -import { AutocompleteInput } from "../autocomplete/util/types"; -import { ProfileDescription } from "../config/ConfigHandler"; -import { SharedConfigSchema } from "../config/sharedConfig"; export type OnboardingModes = | "Local" @@ -195,4 +198,5 @@ export type ToCoreFromIdeOrWebviewProtocol = { ]; "clipboardCache/add": [{ content: string }, void]; "controlPlane/openUrl": [{ path: string }, void]; + "controlPlane/listOrganizations": [undefined, OrganizationDescription[]]; }; diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index 0ce81bfe8..edf079157 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -61,6 +61,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = "didChangeSelectedProfile", "tools/call", "controlPlane/openUrl", + "controlPlane/listOrganizations", ]; // Message types to pass through from core to webview diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt index 2388ce8ab..873add597 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt @@ -117,7 +117,9 @@ class MessageTypes { "profiles/switch", "didChangeSelectedProfile", "tools/call", - "controlPlane/openUrl" + "controlPlane/openUrl", + "controlPlane/listOrganizations" + ) } } \ No newline at end of file diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 4ca866899..19a191f06 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.256", + "version": "0.9.258", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.256", + "version": "0.9.258", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index 248beee42..f1216ac3f 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -1,10 +1,6 @@ import { Popover } from "@headlessui/react"; -import { - ChevronDownIcon, - ComputerDesktopIcon, - SparklesIcon, -} from "@heroicons/react/24/outline"; -import { cloneElement, useEffect, useRef } from "react"; +import { ChevronDownIcon } from "@heroicons/react/24/outline"; +import { useEffect, useRef } from "react"; import { useAuth } from "../../../context/Auth"; import { useAppDispatch } from "../../../redux/hooks"; import { cycleProfile } from "../../../redux/thunks/cycleProfile"; diff --git a/gui/src/context/Auth.tsx b/gui/src/context/Auth.tsx index c81aa1bc1..23fc76c85 100644 --- a/gui/src/context/Auth.tsx +++ b/gui/src/context/Auth.tsx @@ -1,4 +1,7 @@ -import { ProfileDescription } from "core/config/ProfileLifecycleManager"; +import { + OrganizationDescription, + ProfileDescription, +} from "core/config/ProfileLifecycleManager"; import { ControlPlaneSessionInfo } from "core/control-plane/client"; import React, { createContext, @@ -28,6 +31,8 @@ interface AuthContextType { selectedProfile: ProfileDescription | undefined; profiles: ProfileDescription[]; controlServerBetaEnabled: boolean; + organizations: OrganizationDescription[]; + selectedOrganization: OrganizationDescription | undefined; } const AuthContext = createContext(undefined); @@ -39,6 +44,18 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ undefined, ); + const [organizations, setOrganizations] = useState( + [], + ); + + const selectedOrganizationId = useAppSelector( + (store) => store.session.selectedOrganizationId, + ); + + const selectedOrganization = useMemo(() => { + return organizations.find((p) => p.id === selectedOrganizationId); + }, [organizations, selectedOrganizationId]); + const profiles = useAppSelector(selectAvailableProfiles); const selectedProfileId = useAppSelector( @@ -51,10 +68,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ const ideMessenger = useContext(IdeMessengerContext); const dispatch = useDispatch(); - const lastControlServerBetaEnabledStatus = useAppSelector( - (state) => state.misc.lastControlServerBetaEnabledStatus, - ); - const login: AuthContextType["login"] = (useOnboarding: boolean) => { return new Promise((resolve) => { ideMessenger @@ -142,11 +155,23 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ enableControlServerBeta || continueTestEnvironment !== "none"; setControlServerBetaEnabled(enabled); dispatch(setLastControlServerBetaEnabledStatus(enabled)); - - const shouldShowPopup = !lastControlServerBetaEnabledStatus && enabled; }); }, []); + useEffect(() => { + if (session) { + ideMessenger + .request("controlPlane/listOrganizations", undefined) + .then((result) => { + if (result.status === "success") { + setOrganizations(result.content); + } + }); + } else { + setOrganizations([]); + } + }, [session]); + useWebviewListener( "didChangeIdeSettings", async (msg) => { @@ -185,6 +210,8 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ login, selectedProfile, profiles, + selectedOrganization, + organizations, controlServerBetaEnabled, }} > diff --git a/gui/src/pages/config/ScopeSelect.tsx b/gui/src/pages/config/ScopeSelect.tsx index b6798b012..773ad180f 100644 --- a/gui/src/pages/config/ScopeSelect.tsx +++ b/gui/src/pages/config/ScopeSelect.tsx @@ -1,3 +1,5 @@ +// gui/src/pages/config/ScopeSelect.tsx + import { Listbox } from "@headlessui/react"; import { ChevronDownIcon, @@ -5,46 +7,73 @@ import { CubeIcon, } from "@heroicons/react/24/outline"; import { useState } from "react"; +import { useAuth } from "../../context/Auth"; +import { useDispatch } from "react-redux"; +import { setSelectedOrganizationId } from "../../redux/slices/sessionSlice"; export function ScopeSelect() { - const [value, setValue] = useState(""); - const [showAbove, setShowAbove] = useState(false); + const { organizations, selectedOrganization } = useAuth(); + const [value, setValue] = useState( + selectedOrganization?.id || "personal", + ); + const dispatch = useDispatch(); + + const handleChange = (newValue: string) => { + setValue(newValue); + dispatch( + setSelectedOrganizationId(newValue === "personal" ? null : newValue), + ); + }; + const selectedDisplay = + value === "personal" + ? { name: "Personal", iconUrl: null } + : organizations.find((org) => org.id === value); return ( - +
- - Continue + {selectedDisplay?.iconUrl ? ( + + ) : ( + + )} + + {selectedDisplay?.name || "Select Organization"} +
- -
+ +
Organizations
- - -
- - Continue -
-
+ {organizations.map((org) => ( + +
+ {org.iconUrl ? ( + + ) : ( + + )} + {org.name} +
+
+ ))}
diff --git a/gui/src/pages/config/index.tsx b/gui/src/pages/config/index.tsx index 374ee1b42..761bd6e3a 100644 --- a/gui/src/pages/config/index.tsx +++ b/gui/src/pages/config/index.tsx @@ -8,10 +8,16 @@ import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { updateConfig } from "../../redux/slices/configSlice"; import ToggleSwitch from "../../components/gui/Switch"; import { useAuth } from "../../context/Auth"; -import { Input, SecondaryButton, Select } from "../../components"; +import { Input, SecondaryButton } from "../../components"; import { getFontSize } from "../../util"; import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline"; import { ScopeSelect } from "./ScopeSelect"; +import { + SharedConfigSchema, + modifyContinueConfigWithSharedConfig, +} from "core/config/sharedConfig"; +import NumberInput from "../../components/gui/NumberInput"; +import { Select } from "../../components/gui/Select"; function ConfigPage() { useNavigationListener(); @@ -19,7 +25,7 @@ function ConfigPage() { const navigate = useNavigate(); const ideMessenger = useContext(IdeMessengerContext); - const { selectedProfile } = useAuth(); + const { selectedProfile, selectedOrganization } = useAuth(); const config = useAppSelector((state) => state.config.config); function handleUpdate(sharedConfig: Partial) { @@ -99,7 +105,7 @@ function ConfigPage() { if (!selectedProfile) { return (
- navigate("/")} title="Chat" /> + navigate("/")} title="Chat" />

Continue Config

@@ -112,16 +118,20 @@ function ConfigPage() { return (
- navigate("/")} title="Chat" /> + navigate("/")} title="Chat" />

Account

- - You are currently signed in to{" "} - ORG_NAME - + {selectedOrganization?.name && ( + + You are currently signed in to{" "} + + {selectedOrganization?.name} + + + )}
@@ -277,87 +287,103 @@ function ConfigPage() { /> +
{ e.preventDefault(); handleSubmitPromptPath(); }} > -