diff --git a/gui/src/components/AccountDialog.tsx b/gui/src/components/AccountDialog.tsx
index 7d9238c7b..cfd712549 100644
--- a/gui/src/components/AccountDialog.tsx
+++ b/gui/src/components/AccountDialog.tsx
@@ -5,10 +5,11 @@ import {
} from "@heroicons/react/24/outline";
import { UserCircleIcon as UserCircleIconSolid } from "@heroicons/react/24/solid";
import { ProfileDescription } from "core/config/ConfigHandler";
-import { Fragment, useContext, useState } from "react";
+import { Fragment, useContext, useRef, useState } from "react";
import ReactDOM from "react-dom";
import styled from "styled-components";
import {
+ Button,
defaultBorderRadius,
lightGray,
vscBackground,
@@ -118,102 +119,97 @@ function AccountDialog() {
controlServerBetaEnabled,
} = useAuth();
- const topDiv = document.getElementById("profile-select-top-div");
+ // These shouldn't usually show but just to be safe
+ if (!session?.account?.id) {
+ return (
+
+
Account
+
Not signed in
+
+
+ );
+ }
+
+ if (!controlServerBetaEnabled) {
+ return (
+
+
Account
+
+ Continue for teams is not enabled. You can enable it in your IDE
+ settings
+
+
Using local config.
+
+
+ );
+ }
+
+ const topDiv = useRef(null);
return (
-
-
Profiles
- {/*
-
- Continue pre-indexes many common documentation sites, but if there's
- one you don't see in the dropdown, enter the URL here.
-
-
-
- Continue's indexing engine will crawl the site and generate embeddings
- so that you can ask questions.
-
*/}
-
-
- {controlServerBetaEnabled && session?.account?.id && (
-
{
- ideMessenger.post("didChangeSelectedProfile", { id });
- }}
- >
-
-
- {selectedProfile?.title}
-
-
Account
+ {!!topDiv.current &&
+ ReactDOM.createPortal(
+
+
+ {profiles.map((option, idx) => (
+ 1}
/>
+ ))}
+
+ {profiles.length === 0 ? (
+ No workspaces found
+ ) : (
+ "Select workspace"
+ )}
-
- {topDiv &&
- ReactDOM.createPortal(
-
-
- {profiles.map((option, idx) => (
- 1}
- />
- ))}
-
- {profiles.length === 0 ? (
- No workspaces found
- ) : (
- "Select workspace"
- )}
-
-
- ,
- topDiv,
- )}
-
-
- )}
-
- {controlServerBetaEnabled &&
- (session?.account ? (
-
-
-
- ) : (
-
-
-
- ))}
+
+ ,
+ topDiv.current,
+ )}
+ {
+ ideMessenger.post("didChangeSelectedProfile", { id });
+ }}
+ >
+
+
+ {selectedProfile?.title}
+
+
+
+
+
+
+
+ {session.account.label === ""
+ ? "Signed in"
+ : `Signed in as ${session.account.label}`}
+
+
);
}
diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx
index aaf0b757e..173ee7368 100644
--- a/gui/src/components/Layout.tsx
+++ b/gui/src/components/Layout.tsx
@@ -52,14 +52,6 @@ const GridDiv = styled.div`
overflow-x: visible;
`;
-const ModelDropdownPortalDiv = styled.div`
- background-color: ${vscInputBackground};
- position: relative;
- margin-left: 8px;
- z-index: 200;
- font-size: ${getFontSize()};
-`;
-
const ProfileDropdownPortalDiv = styled.div`
background-color: ${vscInputBackground};
position: relative;
@@ -266,7 +258,6 @@ const Layout = () => {
)}
-
diff --git a/gui/src/components/ProfileSwitcher.tsx b/gui/src/components/ProfileSwitcher.tsx
new file mode 100644
index 000000000..601de6782
--- /dev/null
+++ b/gui/src/components/ProfileSwitcher.tsx
@@ -0,0 +1,274 @@
+import { Listbox, Transition } from "@headlessui/react";
+import {
+ ChevronUpDownIcon,
+ UserCircleIcon as UserCircleIconOutline,
+} from "@heroicons/react/24/outline";
+import { UserCircleIcon as UserCircleIconSolid } from "@heroicons/react/24/solid";
+import { ProfileDescription } from "core/config/ConfigHandler";
+import { Fragment, useContext, useEffect, useState } from "react";
+import ReactDOM from "react-dom";
+import { useDispatch, useSelector } from "react-redux";
+import styled from "styled-components";
+import {
+ defaultBorderRadius,
+ lightGray,
+ vscBackground,
+ vscForeground,
+ vscInputBackground,
+ vscListActiveBackground,
+ vscListActiveForeground,
+} from ".";
+import { IdeMessengerContext } from "../context/IdeMessenger";
+import { useAuth } from "../hooks/useAuth";
+import { useWebviewListener } from "../hooks/useWebviewListener";
+import { setLastControlServerBetaEnabledStatus } from "../redux/slices/miscSlice";
+import { RootState } from "../redux/store";
+import { getFontSize } from "../util";
+import HeaderButtonWithToolTip from "./gui/HeaderButtonWithToolTip";
+
+const StyledListbox = styled(Listbox)`
+ background-color: ${vscBackground};
+ min-width: 80px;
+`;
+
+const StyledListboxButton = styled(Listbox.Button)`
+ position: relative;
+ cursor: pointer;
+ background-color: ${vscBackground};
+ text-align: left;
+ border: none;
+ margin: 0;
+ height: 100%;
+ width: 100%;
+ max-width: 180px;
+ white-space: nowrap;
+ overflow: hidden;
+
+ border: 0.5px solid ${lightGray};
+ border-radius: ${defaultBorderRadius};
+
+ display: grid;
+ grid-template-columns: 1fr auto;
+ align-items: center;
+
+ color: ${vscForeground};
+
+ padding: 3px 6px;
+
+ &:focus {
+ outline: none;
+ }
+
+ &:hover {
+ background-color: ${vscInputBackground};
+ }
+
+ font-size: ${getFontSize() - 2}px;
+`;
+
+const StyledListboxOptions = styled(Listbox.Options)`
+ background-color: ${vscInputBackground};
+ padding: 0;
+
+ position: absolute;
+ bottom: calc(100% - 16px);
+ max-width: 100%;
+ max-height: 80vh;
+
+ border-radius: ${defaultBorderRadius};
+ overflow-y: scroll;
+`;
+
+const StyledListboxOption = styled(Listbox.Option)<{ selected: boolean }>`
+ background-color: ${({ selected }) =>
+ selected ? vscListActiveBackground : vscInputBackground};
+ cursor: pointer;
+ padding: 6px 8px;
+
+ &:hover {
+ background-color: ${vscListActiveBackground};
+ color: ${vscListActiveForeground};
+ }
+`;
+
+function ListBoxOption({
+ option,
+ idx,
+ showDelete,
+ selected,
+}: {
+ option: ProfileDescription;
+ idx: number;
+ showDelete?: boolean;
+ selected: boolean;
+}) {
+ const [hovered, setHovered] = useState(false);
+
+ return (
+ {
+ setHovered(true);
+ }}
+ onMouseLeave={() => {
+ setHovered(false);
+ }}
+ >
+
+ {option.title}
+
+
+ );
+}
+
+function ProfileSwitcher() {
+ const ideMessenger = useContext(IdeMessengerContext);
+ const { session, logout, login } = useAuth();
+ const [profiles, setProfiles] = useState([]);
+
+ const dispatch = useDispatch();
+ const lastControlServerBetaEnabledStatus = useSelector(
+ (state: RootState) => state.misc.lastControlServerBetaEnabledStatus,
+ );
+
+ const selectedProfileId = useSelector(
+ (store: RootState) => store.state.selectedProfileId,
+ );
+
+ const [controlServerBetaEnabled, setControlServerBetaEnabled] =
+ useState(false);
+
+ useEffect(() => {
+ ideMessenger.ide.getIdeSettings().then(({ enableControlServerBeta }) => {
+ setControlServerBetaEnabled(enableControlServerBeta);
+ dispatch(setLastControlServerBetaEnabledStatus(enableControlServerBeta));
+
+ const shouldShowPopup =
+ !lastControlServerBetaEnabledStatus && enableControlServerBeta;
+ if (shouldShowPopup) {
+ ideMessenger.ide.showToast("info", "Continue for Teams enabled");
+ }
+ });
+ }, []);
+
+ useWebviewListener(
+ "didChangeIdeSettings",
+ async (msg) => {
+ const { settings } = msg;
+ setControlServerBetaEnabled(settings.enableControlServerBeta);
+ dispatch(
+ setLastControlServerBetaEnabledStatus(settings.enableControlServerBeta),
+ );
+ },
+ [],
+ );
+
+ useEffect(() => {
+ ideMessenger
+ .request("config/listProfiles", undefined)
+ .then(
+ (result) => result.status === "success" && setProfiles(result.content),
+ );
+ }, []);
+
+ useWebviewListener(
+ "didChangeAvailableProfiles",
+ async (data) => {
+ setProfiles(data.profiles);
+ },
+ [],
+ );
+
+ const topDiv = document.getElementById("profile-select-top-div");
+
+ function selectedProfile() {
+ return profiles.find((p) => p.id === selectedProfileId);
+ }
+
+ return (
+ <>
+ {controlServerBetaEnabled && session?.account?.id && (
+ {
+ ideMessenger.post("didChangeSelectedProfile", { id });
+ }}
+ >
+
+
+ {selectedProfile()?.title}
+
+
+
+
+ {topDiv &&
+ ReactDOM.createPortal(
+
+
+ {profiles.map((option, idx) => (
+ 1}
+ />
+ ))}
+
+ {profiles.length === 0 ? (
+ No workspaces found
+ ) : (
+ "Select workspace"
+ )}
+
+
+ ,
+ topDiv,
+ )}
+
+
+ )}
+
+ {controlServerBetaEnabled &&
+ (session?.account ? (
+
+
+
+ ) : (
+
+
+
+ ))}
+ >
+ );
+}
+
+export default ProfileSwitcher;