diff --git a/core/config/ConfigHandler.test.ts b/core/config/ConfigHandler.test.ts index deb1deded..d0ce96207 100644 --- a/core/config/ConfigHandler.test.ts +++ b/core/config/ConfigHandler.test.ts @@ -14,7 +14,7 @@ describe.skip("Test the ConfigHandler and E2E config loading", () => { expect(profiles[0].id).toBe("local"); const currentProfile = testConfigHandler.currentProfile; - expect(currentProfile.profileDescription.id).toBe("local"); + expect(currentProfile?.profileDescription.id).toBe("local"); }); test("should load the default config successfully", async () => { diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index 2cc8fd8ac..66b53e30d 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -48,8 +48,9 @@ export class ConfigHandler { private readonly globalContext = new GlobalContext(); private additionalContextProviders: IContextProvider[] = []; private profiles: ProfileLifecycleManager[]; - private selectedProfileId: string; + private selectedProfileId: string | null; private selectedOrgId: string | null; + private localProfileManager: ProfileLifecycleManager; constructor( private readonly ide: IDE, @@ -68,21 +69,25 @@ export class ConfigHandler { controlPlaneClient, writeLog, ); - this.profiles = [new ProfileLifecycleManager(localProfileLoader, this.ide)]; + this.localProfileManager = new ProfileLifecycleManager( + localProfileLoader, + this.ide, + ); + this.profiles = [this.localProfileManager]; this.selectedProfileId = localProfileLoader.description.id; this.selectedOrgId = null; - // Always load local profile immediately in case control plane doesn't load - try { - void this.loadConfig(); - } catch (e) { - console.error("Failed to load config: ", e); - } - void this.init(); } private async init() { + // Always load local profile immediately in case control plane doesn't load + try { + await this.loadConfig(); + } catch (e) { + console.error("Failed to load config: ", e); + } + const workspaceId = await this.getWorkspaceId(); const lastSelectedOrgIds = this.globalContext.get("lastSelectedOrgIdForWorkspace") ?? {}; @@ -97,16 +102,17 @@ export class ConfigHandler { void this.fetchControlPlaneProfiles(); } - // This will be the local profile - private get fallbackProfile() { - return this.profiles[0]; - } - get currentProfile() { + if (!this.selectedProfileId) { + return null; + } + // IMPORTANT + // We must fall back to null, not the first or local profiles + // Because GUI must be the source of truth for selected profile return ( this.profiles.find( (p) => p.profileDescription.id === this.selectedProfileId, - ) ?? this.fallbackProfile + ) ?? null ); } @@ -169,12 +175,10 @@ export class ConfigHandler { }), ); - this.profiles = [ - ...this.profiles.filter( - (profile) => profile.profileDescription.id === "local", - ), - ...hubProfiles, - ]; + this.profiles = + this.selectedOrgId === null + ? [this.localProfileManager, ...hubProfiles] + : hubProfiles; this.notifyProfileListeners( this.profiles.map((profile) => profile.profileDescription), @@ -182,19 +186,19 @@ export class ConfigHandler { // Check the last selected workspace, and reload if it isn't local const workspaceId = await this.getWorkspaceId(); - const lastSelectedWorkspaceIds = + const lastSelectedIds = this.globalContext.get("lastSelectedProfileForWorkspace") ?? {}; - const selectedWorkspaceId = lastSelectedWorkspaceIds[workspaceId]; - if (selectedWorkspaceId) { - this.selectedProfileId = selectedWorkspaceId; + const selectedProfileId = lastSelectedIds[workspaceId]; + if (selectedProfileId) { + this.selectedProfileId = selectedProfileId; await this.loadConfig(); } else { // Otherwise we stick with local profile, and record choice - lastSelectedWorkspaceIds[workspaceId] = this.selectedProfileId; + lastSelectedIds[workspaceId] = this.selectedProfileId; this.globalContext.update( "lastSelectedProfileForWorkspace", - lastSelectedWorkspaceIds, + lastSelectedIds, ); } }) @@ -253,9 +257,7 @@ export class ConfigHandler { this.controlPlaneClient .listWorkspaces() .then(async (workspaces) => { - this.profiles = this.profiles.filter( - (profile) => profile.profileDescription.id === "local", - ); + this.profiles = [this.localProfileManager]; workspaces.forEach((workspace) => { const profileLoader = new ControlPlaneProfileLoader( workspace.id, @@ -277,18 +279,18 @@ export class ConfigHandler { // Check the last selected workspace, and reload if it isn't local const workspaceId = await this.getWorkspaceId(); - const lastSelectedWorkspaceIds = + const lastSelectedIds = this.globalContext.get("lastSelectedProfileForWorkspace") ?? {}; - const selectedWorkspaceId = lastSelectedWorkspaceIds[workspaceId]; - if (selectedWorkspaceId) { - this.selectedProfileId = selectedWorkspaceId; + const selectedProfileId = lastSelectedIds[workspaceId]; + if (selectedProfileId) { + this.selectedProfileId = selectedProfileId; await this.loadConfig(); } else { // Otherwise we stick with local profile, and record choice - lastSelectedWorkspaceIds[workspaceId] = this.selectedProfileId; + lastSelectedIds[workspaceId] = this.selectedProfileId; this.globalContext.update( "lastSelectedProfileForWorkspace", - lastSelectedWorkspaceIds, + lastSelectedIds, ); } }) @@ -306,7 +308,7 @@ export class ConfigHandler { this.globalContext.update("lastSelectedOrgIdForWorkspace", selectedOrgs); } - async setSelectedProfile(profileId: string) { + async setSelectedProfile(profileId: string | null) { this.selectedProfileId = profileId; const result = await this.loadConfig(); this.notifyConfigListeners(result); @@ -369,8 +371,15 @@ export class ConfigHandler { this.updateListeners.push(listener); } + // TODO: this isn't right, there are two different senses in which you want to "reload" async reloadConfig() { - // TODO: this isn't right, there are two different senses in which you want to "reload" + if (!this.currentProfile) { + return { + config: undefined, + errors: [], + configLoadInterrupted: true, + }; + } const { config, errors, configLoadInterrupted } = await this.currentProfile.reloadConfig(this.additionalContextProviders); @@ -380,13 +389,20 @@ export class ConfigHandler { } this.notifyConfigListeners({ config, errors, configLoadInterrupted }); - return { config, errors }; + return { config, errors, configLoadInterrupted }; } - getSerializedConfig(): Promise< + async getSerializedConfig(): Promise< ConfigResult > { - return this.currentProfile.getSerializedConfig( + if (!this.currentProfile) { + return { + config: undefined, + errors: [], + configLoadInterrupted: true, + }; + } + return await this.currentProfile.getSerializedConfig( this.additionalContextProviders, ); } @@ -396,6 +412,13 @@ export class ConfigHandler { } async loadConfig(): Promise> { + if (!this.currentProfile) { + return { + config: undefined, + errors: [], + configLoadInterrupted: true, + }; + } return await this.currentProfile.loadConfig( this.additionalContextProviders, ); diff --git a/core/core.ts b/core/core.ts index 5a2448e83..f84e1f6ac 100644 --- a/core/core.ts +++ b/core/core.ts @@ -73,10 +73,6 @@ export class Core { private abortedMessageIds: Set = new Set(); - private async config() { - return (await this.configHandler.loadConfig()).config; - } - invoke( messageType: T, data: ToCoreProtocol[T][0], @@ -136,7 +132,8 @@ export class Core { const serializedResult = await this.configHandler.getSerializedConfig(); this.messenger.send("configUpdate", { result: serializedResult, - profileId: this.configHandler.currentProfile.profileDescription.id, + profileId: + this.configHandler.currentProfile?.profileDescription.id ?? null, }); }); @@ -281,10 +278,8 @@ export class Core { }); on("config/newPromptFile", async (msg) => { - await createNewPromptFileV2( - this.ide, - (await this.config())?.experimental?.promptPath, - ); + const { config } = await this.configHandler.loadConfig(); + await createNewPromptFileV2(this.ide, config?.experimental?.promptPath); await this.configHandler.reloadConfig(); }); @@ -341,7 +336,7 @@ export class Core { }); on("context/loadSubmenuItems", async (msg) => { - const config = await this.config(); + const { config } = await this.configHandler.loadConfig(); if (!config) { return []; } @@ -358,13 +353,14 @@ export class Core { }); on("context/getContextItems", async (msg) => { - const { name, query, fullInput, selectedCode, selectedModelTitle } = - msg.data; - const config = await this.config(); + const { config } = await this.configHandler.loadConfig(); if (!config) { return []; } + const { name, query, fullInput, selectedCode, selectedModelTitle } = + msg.data; + const llm = await this.configHandler.llmFromTitle(selectedModelTitle); const provider = config.contextProviders?.find( @@ -454,7 +450,8 @@ export class Core { on("config/getSerializedProfileInfo", async (msg) => { return { result: await this.configHandler.getSerializedConfig(), - profileId: this.configHandler.currentProfile.profileDescription.id, + profileId: + this.configHandler.currentProfile?.profileDescription.id ?? null, }; }); diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 82ce4eea7..c3084f6b8 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -62,7 +62,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { undefined, { result: ConfigResult; - profileId: string; + profileId: string | null; }, ]; "config/deleteModel": [{ title: string }, void]; @@ -184,8 +184,6 @@ export type ToCoreFromIdeOrWebviewProtocol = { "docs/getDetails": [{ startUrl: string }, DocsIndexingDetails]; addAutocompleteModel: [{ model: ModelDescription }, void]; - "profiles/switch": [{ id: string }, undefined]; - "auth/getAuthUrl": [{ useOnboarding: boolean }, { url: string }]; "tools/call": [ { toolCall: ToolCall; selectedModelTitle: string }, diff --git a/core/protocol/coreWebview.ts b/core/protocol/coreWebview.ts index e8ef70ab9..ff99acd03 100644 --- a/core/protocol/coreWebview.ts +++ b/core/protocol/coreWebview.ts @@ -4,7 +4,7 @@ import { ToCoreFromIdeOrWebviewProtocol } from "./core.js"; import { ToWebviewFromIdeOrCoreProtocol } from "./webview.js"; export type ToCoreFromWebviewProtocol = ToCoreFromIdeOrWebviewProtocol & { - didChangeSelectedProfile: [{ id: string }, void]; + didChangeSelectedProfile: [{ id: string | null }, void]; didChangeSelectedOrg: [{ id: string | null }, void]; }; export type ToWebviewFromCoreProtocol = ToWebviewFromIdeOrCoreProtocol & { diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index 8ee0c5ae8..f0c66f465 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -57,7 +57,6 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = // "completeOnboarding", "addAutocompleteModel", - "profiles/switch", "didChangeSelectedProfile", "didChangeSelectedOrg", "tools/call", @@ -82,7 +81,5 @@ export const CORE_TO_WEBVIEW_PASS_THROUGH: (keyof ToWebviewFromCoreProtocol)[] = "setTTSActive", "getWebviewHistoryLength", "getCurrentSessionId", - "signInToControlPlane", - "openDialogMessage", "docs/suggestions", ]; diff --git a/core/protocol/webview.ts b/core/protocol/webview.ts index 013efbbd7..90df4bd0f 100644 --- a/core/protocol/webview.ts +++ b/core/protocol/webview.ts @@ -12,7 +12,7 @@ export type ToWebviewFromIdeOrCoreProtocol = { configUpdate: [ { result: ConfigResult; - profileId: string; + profileId: string | null; }, void, ]; @@ -37,8 +37,6 @@ export type ToWebviewFromIdeOrCoreProtocol = { setTTSActive: [boolean, void]; getWebviewHistoryLength: [undefined, number]; getCurrentSessionId: [undefined, string]; - signInToControlPlane: [undefined, void]; - openDialogMessage: ["account", void]; "docs/suggestions": [PackageDocsResult[], void]; "jetbrains/setColors": [Record, void]; }; diff --git a/core/util/GlobalContext.ts b/core/util/GlobalContext.ts index 121c45946..34c3d8ddf 100644 --- a/core/util/GlobalContext.ts +++ b/core/util/GlobalContext.ts @@ -12,7 +12,9 @@ import { SiteIndexingConfig } from ".."; export type GlobalContextType = { indexingPaused: boolean; selectedTabAutocompleteModel: string; - lastSelectedProfileForWorkspace: { [workspaceIdentifier: string]: string }; + lastSelectedProfileForWorkspace: { + [workspaceIdentifier: string]: string | null; + }; lastSelectedOrgIdForWorkspace: { [workspaceIdentifier: string]: string | null; }; diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt index 8e2d34de4..3c6b27f05 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt @@ -134,11 +134,4 @@ class OpenMorePageAction : AnAction() { val params = mapOf("path" to "/more", "toggle" to true) continuePluginService.sendToWebview("navigateTo", params) } -} - -class OpenAccountDialogAction : AnAction() { - override fun actionPerformed(e: AnActionEvent) { - val continuePluginService = getContinuePluginService(e.project) ?: return - continuePluginService.sendToWebview("openDialogMessage", "account") - } } \ No newline at end of file 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 542ef6ef7..bb362b382 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 @@ -70,8 +70,6 @@ class MessageTypes { "setTTSActive", "getWebviewHistoryLength", "getCurrentSessionId", - "signInToControlPlane", - "openDialogMessage", "docs/suggestions", ) @@ -126,7 +124,6 @@ class MessageTypes { // "completeOnboarding", "addAutocompleteModel", - "profiles/switch", "didChangeSelectedProfile", "didChangeSelectedOrg", "tools/call", diff --git a/extensions/intellij/src/main/resources/META-INF/plugin.xml b/extensions/intellij/src/main/resources/META-INF/plugin.xml index 5a43ff24f..abc50a092 100644 --- a/extensions/intellij/src/main/resources/META-INF/plugin.xml +++ b/extensions/intellij/src/main/resources/META-INF/plugin.xml @@ -140,14 +140,6 @@ - - - - - diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 3c8438d7a..aac242ad8 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -94,7 +94,7 @@ "continue.enableContinueForTeams": { "type": "boolean", "default": false, - "markdownDescription": "Enable Continue for teams beta features. To sign in, click the person icon in the bottom right of the sidebar." + "markdownDescription": "Enable Continue for teams beta features. To sign in, click the gear icon to go to the settings page, and click Sign In." }, "continue.enableContinueHub": { "type": "boolean", @@ -328,20 +328,6 @@ "category": "Continue", "title": "Focus Continue Chat", "group": "Continue" - }, - { - "command": "continue.signInToControlPlane", - "title": "Sign In", - "category": "Continue", - "group": "Continue", - "icon": "$(account)" - }, - { - "command": "continue.openAccountDialog", - "title": "Account", - "category": "Continue", - "group": "Continue", - "icon": "$(account)" } ], "keybindings": [ @@ -531,16 +517,6 @@ "group": "navigation@4", "when": "view == continue.continueGUIView" }, - { - "command": "continue.signInToControlPlane", - "group": "navigation@5", - "when": "(view == continue.continueGUIView) && (config.continue.enableContinueForTeams || config.continue.enableContinueHub) && !continue.isSignedInToControlPlane" - }, - { - "command": "continue.openAccountDialog", - "group": "navigation@5", - "when": "(view == continue.continueGUIView) && (config.continue.enableContinueForTeams || config.continue.enableContinueHub) && continue.isSignedInToControlPlane" - }, { "command": "continue.openMorePage", "group": "navigation@6", diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 02afcdcec..d99bbd5ae 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -916,7 +916,8 @@ const getCommandsMap: ( }, { label: "$(screen-full) Open full screen chat", - description: getMetaKeyLabel() + " + K, " + getMetaKeyLabel() + " + M", + description: + getMetaKeyLabel() + " + K, " + getMetaKeyLabel() + " + M", }, { label: quickPickStatusText(targetStatus), @@ -998,12 +999,6 @@ const getCommandsMap: ( sidebar.webviewProtocol?.request("navigateTo", { path, toggle }); focusGUI(); }, - "continue.signInToControlPlane": () => { - sidebar.webviewProtocol?.request("signInToControlPlane", undefined); - }, - "continue.openAccountDialog": () => { - sidebar.webviewProtocol?.request("openDialogMessage", "account"); - }, "continue.startLocalOllama": () => { startLocalOllama(ide); }, diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts index 7d483b2bb..470320f44 100644 --- a/extensions/vscode/src/extension/VsCodeExtension.ts +++ b/extensions/vscode/src/extension/VsCodeExtension.ts @@ -168,12 +168,6 @@ export class VsCodeExtension { } else if (newConfig) { setupStatusBar(undefined, undefined, false); - const result = await this.configHandler.getSerializedConfig(); - this.sidebar.webviewProtocol?.request("configUpdate", { - result, - profileId: this.configHandler.currentProfile.profileDescription.id, - }); - this.tabAutocompleteModel.clearLlm(); registerAllCodeLensProviders( @@ -182,8 +176,6 @@ export class VsCodeExtension { newConfig, ); } - - this.sidebar.webviewProtocol?.request("configError", errors); }, ); diff --git a/gui/src/components/AccountDialog.tsx b/gui/src/components/AccountDialog.tsx deleted file mode 100644 index 1081a27ef..000000000 --- a/gui/src/components/AccountDialog.tsx +++ /dev/null @@ -1,148 +0,0 @@ -import { Listbox, Transition } from "@headlessui/react"; -import { ChevronUpDownIcon } from "@heroicons/react/24/outline"; -import { Fragment, useContext } from "react"; -import { useDispatch } from "react-redux"; -import styled from "styled-components"; -import { - Button, - SecondaryButton, - vscInputBackground, - vscListActiveBackground, - vscListActiveForeground, -} from "."; -import { useAuth } from "../context/Auth"; -import { IdeMessengerContext } from "../context/IdeMessenger"; -import { setSelectedProfileId } from "../redux/slices/sessionSlice"; -import { setDialogMessage, setShowDialog } from "../redux/slices/uiSlice"; -import { getFontSize } from "../util"; - -const StyledListboxOption = styled(Listbox.Option)<{ selected: boolean }>` - background-color: ${({ selected }) => - selected ? vscListActiveBackground : vscInputBackground}; - cursor: pointer; - padding: 4px 6px; - font-size: ${getFontSize() - 1}px; - - &:hover { - background-color: ${vscListActiveBackground}; - color: ${vscListActiveForeground}; - } -`; - -export default function AccountDialog() { - const ideMessenger = useContext(IdeMessengerContext); - const { - session, - logout, - login, - profiles, - selectedProfile, - controlServerBetaEnabled, - } = useAuth(); - - // These shouldn't usually show but just to be safe - if (!session?.account?.id) { - return ( -
-

Account

- - Signed out - - -
- ); - } - - const dispatch = useDispatch(); - - const changeProfileId = (id: string) => { - ideMessenger.post("didChangeSelectedProfile", { id }); - dispatch(setSelectedProfileId(id)); - }; - - return ( -
-
-

Account

- - {session.account.label === "" ? ( - "Signed in" - ) : ( - <> - Signed in as {session.account.id} - - )} - -
- - {controlServerBetaEnabled && ( -
- Current workspace - - - {({ open }) => ( -
- - - {selectedProfile?.title} - -
-
-
- - - - {profiles.map((option, idx) => ( - - - {option.title} - - - ))} - {profiles.length === 0 && ( -
- No workspaces found -
- )} -
-
-
- )} -
-
- )} - -
- - Sign out - - -
-
- ); -} diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index e9c12f993..b54db7549 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -13,13 +13,12 @@ import { setMode, updateApplyState, } from "../redux/slices/sessionSlice"; -import { setDialogMessage, setShowDialog } from "../redux/slices/uiSlice"; +import { setShowDialog } from "../redux/slices/uiSlice"; import { exitEditMode } from "../redux/thunks"; import { loadLastSession, saveCurrentSession } from "../redux/thunks/session"; import { getFontSize, isMetaEquivalentKeyPressed } from "../util"; import { incrementFreeTrialCount } from "../util/freeTrial"; import { ROUTES } from "../util/navigation"; -import AccountDialog from "./AccountDialog"; import TextDialog from "./dialogs"; import Footer from "./Footer"; import { isNewUserOnboarding, useOnboardingCard } from "./OnboardingCard"; @@ -97,17 +96,6 @@ const Layout = () => { location.pathname === ROUTES.HOME, ); - useWebviewListener( - "openDialogMessage", - async (message) => { - if (message === "account") { - dispatch(setShowDialog(true)); - dispatch(setDialogMessage()); - } - }, - [], - ); - useWebviewListener( "addModel", async () => { diff --git a/gui/src/components/modelSelection/ModelSelectionListbox.tsx b/gui/src/components/modelSelection/ModelSelectionListbox.tsx index aadf4319c..d48ffceed 100644 --- a/gui/src/components/modelSelection/ModelSelectionListbox.tsx +++ b/gui/src/components/modelSelection/ModelSelectionListbox.tsx @@ -4,24 +4,19 @@ import { ChevronUpDownIcon, CubeIcon, } from "@heroicons/react/24/outline"; -import { Dispatch, Fragment, SetStateAction } from "react"; +import { Fragment } from "react"; import { Listbox } from "@headlessui/react"; import styled from "styled-components"; import { defaultBorderRadius, lightGray, vscBackground, - vscButtonBackground, vscForeground, vscInputBackground, vscListActiveBackground, vscListActiveForeground, } from ".."; -import { - DisplayInfo, - ModelPackage, -} from "../../pages/AddNewModel/configs/models"; -import { ProviderInfo } from "../../pages/AddNewModel/configs/providers"; +import { DisplayInfo } from "../../pages/AddNewModel/configs/models"; export const StyledListbox = styled(Listbox)` background-color: ${vscBackground}; diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index 186ebde44..55e60449d 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -3,7 +3,6 @@ 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"; import { getFontSize, isLocalProfile, @@ -13,15 +12,13 @@ import PopoverTransition from "../../mainInput/InputToolbar/PopoverTransition"; import { AssistantSelectOptions } from "./AssistantSelectOptions"; import AssistantIcon from "./AssistantIcon"; import { getProfileDisplayText } from "./utils"; +import { cycleProfile } from "../../../redux/thunks/profileAndOrg"; export default function AssistantSelect() { const dispatch = useAppDispatch(); const buttonRef = useRef(null); const { selectedProfile } = useAuth(); - const isLocalProfileSelected = - selectedProfile && isLocalProfile(selectedProfile); - useEffect(() => { let lastToggleTime = 0; const DEBOUNCE_MS = 500; @@ -57,7 +54,7 @@ export default function AssistantSelect() {
diff --git a/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx b/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx index ab2b6716e..755e0570b 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelectOptions.tsx @@ -5,18 +5,21 @@ import { lightGray } from "../.."; import { useAuth } from "../../../context/Auth"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { useAppDispatch } from "../../../redux/hooks"; -import { setProfileId } from "../../../redux/thunks/setProfileId"; import { getFontSize, getMetaKeyLabel, isLocalProfile } from "../../../util"; import { ROUTES } from "../../../util/navigation"; import AssistantIcon from "./AssistantIcon"; import { Divider, Option, OptionDiv } from "./shared"; import { getProfileDisplayText } from "./utils"; +import { ProfileDescription } from "core/config/ConfigHandler"; +import { selectProfileThunk } from "../../../redux/thunks/profileAndOrg"; interface AssistantSelectOptionsProps { onClose: () => void; } -export function AssistantSelectOptions(props: AssistantSelectOptionsProps) { +export function AssistantSelectOptions({ + onClose, +}: AssistantSelectOptionsProps) { const ideMessenger = useContext(IdeMessengerContext); const { profiles, selectedProfile, selectedOrganization } = useAuth(); const dispatch = useAppDispatch(); @@ -27,60 +30,56 @@ export function AssistantSelectOptions(props: AssistantSelectOptionsProps) { path: "new", orgSlug: selectedOrganization?.slug, }); + onClose(); } - function handleOptionLink(e: React.MouseEvent, profileId: string) { - e.stopPropagation(); - e.preventDefault(); - ideMessenger.post("config/openProfile", { profileId }); - } - - function handleConfigure(e: React.MouseEvent, option: any) { - e.stopPropagation(); - e.preventDefault(); - - ideMessenger.post("config/openProfile", { profileId: option.id }); + function handleConfigure(profile: ProfileDescription) { + ideMessenger.post("config/openProfile", { profileId: profile.id }); + onClose(); } function handleClickError(profileId: string) { ideMessenger.post("config/openProfile", { profileId }); + onClose(); } return (
- {profiles.map((profile, idx) => ( -