From acb436e0ebfe094e51d691b2adbe8649e991e31f Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 20 Mar 2025 15:57:50 -0700 Subject: [PATCH 1/4] improv: simplify --- gui/src/pages/config/AccountManagement.tsx | 160 +++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 gui/src/pages/config/AccountManagement.tsx diff --git a/gui/src/pages/config/AccountManagement.tsx b/gui/src/pages/config/AccountManagement.tsx new file mode 100644 index 000000000..95214278b --- /dev/null +++ b/gui/src/pages/config/AccountManagement.tsx @@ -0,0 +1,160 @@ +import { Listbox, Transition } from "@headlessui/react"; +import { + ArrowTopRightOnSquareIcon, + ChevronUpDownIcon, + PlusCircleIcon, +} from "@heroicons/react/24/outline"; +import { Fragment, useContext, useEffect, useState } from "react"; +import AssistantIcon from "../../components/modelSelection/platform/AssistantIcon"; +import { useAuth } from "../../context/Auth"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { useNavigationListener } from "../../hooks/useNavigationListener"; +import { useAppDispatch } from "../../redux/hooks"; +import { selectProfileThunk } from "../../redux/thunks/profileAndOrg"; +import { ScopeSelect } from "./ScopeSelect"; + +export function AccountManagement() { + useNavigationListener(); + const dispatch = useAppDispatch(); + const ideMessenger = useContext(IdeMessengerContext); + + const { session, login, profiles, selectedProfile, selectedOrganization } = + useAuth(); + + const changeProfileId = (id: string) => { + dispatch(selectProfileThunk(id)); + }; + + const [hubEnabled, setHubEnabled] = useState(false); + + useEffect(() => { + ideMessenger.ide.getIdeSettings().then(({ continueTestEnvironment }) => { + setHubEnabled(continueTestEnvironment === "production"); + }); + }, [ideMessenger]); + + 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...
+ )} +
+
+ ); +} From 6c2bf04006d31392741082f9c67b4f9625ed660f Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 20 Mar 2025 16:02:36 -0700 Subject: [PATCH 2/4] improv: split up components --- gui/src/pages/config/AccountManagement.tsx | 12 +- gui/src/pages/config/index.tsx | 173 +-------------------- 2 files changed, 7 insertions(+), 178 deletions(-) diff --git a/gui/src/pages/config/AccountManagement.tsx b/gui/src/pages/config/AccountManagement.tsx index 95214278b..ade570d80 100644 --- a/gui/src/pages/config/AccountManagement.tsx +++ b/gui/src/pages/config/AccountManagement.tsx @@ -4,7 +4,7 @@ import { ChevronUpDownIcon, PlusCircleIcon, } from "@heroicons/react/24/outline"; -import { Fragment, useContext, useEffect, useState } from "react"; +import { Fragment, useContext } from "react"; import AssistantIcon from "../../components/modelSelection/platform/AssistantIcon"; import { useAuth } from "../../context/Auth"; import { IdeMessengerContext } from "../../context/IdeMessenger"; @@ -13,7 +13,7 @@ import { useAppDispatch } from "../../redux/hooks"; import { selectProfileThunk } from "../../redux/thunks/profileAndOrg"; import { ScopeSelect } from "./ScopeSelect"; -export function AccountManagement() { +export function AccountManagement({ hubEnabled }: { hubEnabled: boolean }) { useNavigationListener(); const dispatch = useAppDispatch(); const ideMessenger = useContext(IdeMessengerContext); @@ -25,14 +25,6 @@ export function AccountManagement() { dispatch(selectProfileThunk(id)); }; - const [hubEnabled, setHubEnabled] = useState(false); - - useEffect(() => { - ideMessenger.ide.getIdeSettings().then(({ continueTestEnvironment }) => { - setHubEnabled(continueTestEnvironment === "production"); - }); - }, [ideMessenger]); - function handleOpenConfig() { if (!selectedProfile) { return; 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 */}
From ade83fd0c6b3f2d3bb8175b6bdbdc0a6e9735c5b Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Fri, 21 Mar 2025 09:25:02 -0700 Subject: [PATCH 3/4] fix: unnecessary dependency --- gui/src/pages/config/AccountManagement.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/gui/src/pages/config/AccountManagement.tsx b/gui/src/pages/config/AccountManagement.tsx index ade570d80..1b9dd80af 100644 --- a/gui/src/pages/config/AccountManagement.tsx +++ b/gui/src/pages/config/AccountManagement.tsx @@ -8,13 +8,11 @@ import { Fragment, useContext } from "react"; import AssistantIcon from "../../components/modelSelection/platform/AssistantIcon"; import { useAuth } from "../../context/Auth"; import { IdeMessengerContext } from "../../context/IdeMessenger"; -import { useNavigationListener } from "../../hooks/useNavigationListener"; import { useAppDispatch } from "../../redux/hooks"; import { selectProfileThunk } from "../../redux/thunks/profileAndOrg"; import { ScopeSelect } from "./ScopeSelect"; export function AccountManagement({ hubEnabled }: { hubEnabled: boolean }) { - useNavigationListener(); const dispatch = useAppDispatch(); const ideMessenger = useContext(IdeMessengerContext); From d9eb118c514fc2a4364f532eb6438588fc9f712c Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Fri, 21 Mar 2025 09:45:44 -0700 Subject: [PATCH 4/4] fix: remove mismatch between last selected profile and current profile --- core/config/ConfigHandler.ts | 10 ---------- 1 file changed, 10 deletions(-) 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();