diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index ddff9bd40..7db61161a 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -387,16 +387,6 @@ export class ConfigHandler { this.ideSettingsPromise, ); - // After login, default to the first org as the selected org - try { - const orgs = await this.controlPlaneClient.listOrganizations(); - if (orgs.length) { - await this.setSelectedOrgId(orgs[0].id); - } - } catch (e) { - console.error("Failed to fetch control plane profiles: ", e); - } - this.fetchControlPlaneProfiles().catch(async (e) => { console.error("Failed to fetch control plane profiles: ", e); await this.loadLocalProfilesOnly(); diff --git a/gui/src/pages/config/AccountManagement.tsx b/gui/src/pages/config/AccountManagement.tsx new file mode 100644 index 000000000..1b9dd80af --- /dev/null +++ b/gui/src/pages/config/AccountManagement.tsx @@ -0,0 +1,150 @@ +import { Listbox, Transition } from "@headlessui/react"; +import { + ArrowTopRightOnSquareIcon, + ChevronUpDownIcon, + PlusCircleIcon, +} from "@heroicons/react/24/outline"; +import { Fragment, useContext } from "react"; +import AssistantIcon from "../../components/modelSelection/platform/AssistantIcon"; +import { useAuth } from "../../context/Auth"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { useAppDispatch } from "../../redux/hooks"; +import { selectProfileThunk } from "../../redux/thunks/profileAndOrg"; +import { ScopeSelect } from "./ScopeSelect"; + +export function AccountManagement({ hubEnabled }: { hubEnabled: boolean }) { + const dispatch = useAppDispatch(); + const ideMessenger = useContext(IdeMessengerContext); + + const { session, login, profiles, selectedProfile, selectedOrganization } = + useAuth(); + + const changeProfileId = (id: string) => { + dispatch(selectProfileThunk(id)); + }; + + function handleOpenConfig() { + if (!selectedProfile) { + return; + } + ideMessenger.post("config/openProfile", { + profileId: selectedProfile.id, + }); + } + + return ( +
+
+

Configuration

+ {hubEnabled ? ( + // Hub: show org selector + session && ( +
+ {`Organization`} + +
+ ) + ) : ( + // Continue for teams: show org text +
You are using Continue for Teams
+ )} + + {profiles ? ( + <> +
+
+ {`${hubEnabled ? "Assistant" : "Profile"}`} +
+ + {({ open }) => ( +
+ +
+ {selectedProfile && ( + + )} + + {selectedProfile?.title ?? "No Assistant Selected"} + +
+
+
+
+ + + + {profiles.map((option, idx) => ( + + + + {option.title} + + + ))} + {hubEnabled && ( + { + if (session) { + ideMessenger.post("controlPlane/openUrl", { + path: "new", + orgSlug: selectedOrganization?.slug, + }); + } else { + login(false); + } + }} + > + + + Create new Assistant + + + )} + + + + {selectedProfile && ( +
+ + + {hubEnabled + ? "Open Assistant configuration" + : "View Workspace"} + +
+ )} +
+ )} +
+
+ + ) : ( +
Loading...
+ )} +
+
+ ); +} diff --git a/gui/src/pages/config/index.tsx b/gui/src/pages/config/index.tsx index 14128ffda..3d975f410 100644 --- a/gui/src/pages/config/index.tsx +++ b/gui/src/pages/config/index.tsx @@ -1,24 +1,16 @@ import { ModelRole } from "@continuedev/config-yaml"; -import { Listbox, Transition } from "@headlessui/react"; -import { - ArrowTopRightOnSquareIcon, - CheckIcon, - ChevronUpDownIcon, - PlusCircleIcon, - XMarkIcon, -} from "@heroicons/react/24/outline"; +import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline"; import { ModelDescription } from "core"; import { SharedConfigSchema, modifyAnyConfigWithSharedConfig, } from "core/config/sharedConfig"; -import { Fragment, useContext, useEffect, useState } from "react"; +import { useContext, useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import { Input } from "../../components"; import NumberInput from "../../components/gui/NumberInput"; import { Select } from "../../components/gui/Select"; import ToggleSwitch from "../../components/gui/Switch"; -import AssistantIcon from "../../components/modelSelection/platform/AssistantIcon"; import PageHeader from "../../components/PageHeader"; import { useAuth } from "../../context/Auth"; import { IdeMessengerContext } from "../../context/IdeMessenger"; @@ -29,11 +21,10 @@ import { setDefaultModel, updateConfig, } from "../../redux/slices/configSlice"; -import { selectProfileThunk } from "../../redux/thunks/profileAndOrg"; import { getFontSize, isJetBrains } from "../../util"; import { AccountButton } from "./AccountButton"; +import { AccountManagement } from "./AccountManagement"; import ModelRoleSelector from "./ModelRoleSelector"; -import { ScopeSelect } from "./ScopeSelect"; function ConfigPage() { useNavigationListener(); @@ -41,19 +32,7 @@ function ConfigPage() { const navigate = useNavigate(); const ideMessenger = useContext(IdeMessengerContext); - const { - session, - logout, - login, - profiles, - selectedProfile, - controlServerBetaEnabled, - selectedOrganization, - } = useAuth(); - - const changeProfileId = (id: string) => { - dispatch(selectProfileThunk(id)); - }; + const { selectedProfile, controlServerBetaEnabled } = useAuth(); const [hubEnabled, setHubEnabled] = useState(false); useEffect(() => { @@ -62,15 +41,6 @@ function ConfigPage() { }); }, [ideMessenger]); - function handleOpenConfig() { - if (!selectedProfile) { - return; - } - ideMessenger.post("config/openProfile", { - profileId: selectedProfile.id, - }); - } - // NOTE Hub takes priority over Continue for Teams // Since teams will be moving to hub, not vice versa @@ -161,23 +131,6 @@ function ConfigPage() { setFormDisableAutocomplete(disableAutocompleteInFiles); }, [disableAutocompleteInFiles]); - // Workspace prompts - const promptPath = config.experimental?.promptPath || ""; - const [formPromptPath, setFormPromptPath] = useState(promptPath); - const cancelChangePromptPath = () => { - setFormPromptPath(promptPath); - }; - const handleSubmitPromptPath = () => { - handleUpdate({ - promptPath: formPromptPath || "", - }); - }; - - useEffect(() => { - // Necessary so that reformatted/trimmed values don't cause dirty state - setFormPromptPath(promptPath); - }, [promptPath]); - const jetbrains = isJetBrains(); return ( @@ -190,123 +143,7 @@ function ConfigPage() { />
-
-
-

Configuration

- {hubEnabled ? ( - // Hub: show org selector - session && ( -
- {`Organization`} - -
- ) - ) : ( - // Continue for teams: show org text -
You are using Continue for Teams
- )} - - {profiles ? ( - <> -
-
- {`${hubEnabled ? "Assistant" : "Profile"}`} -
- - {({ open }) => ( -
- -
- {selectedProfile && ( - - )} - - {selectedProfile?.title ?? - "No Assistant Selected"} - -
-
-
-
- - - - {profiles.map((option, idx) => ( - - - - {option.title} - - - ))} - {hubEnabled && ( - { - if (session) { - ideMessenger.post("controlPlane/openUrl", { - path: "new", - orgSlug: selectedOrganization?.slug, - }); - } else { - login(false); - } - }} - > - - - Create new Assistant - - - )} - - - - {selectedProfile && ( -
- - - {hubEnabled - ? "Open Assistant configuration" - : "View Workspace"} - -
- )} -
- )} -
-
- - ) : ( -
Loading...
- )} -
-
+ {/* Model Roles as a separate section */}