From 8eb97b167b6e600196ef2e8467ca5ded8737e771 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Sun, 6 Apr 2025 16:53:39 -0700 Subject: [PATCH] refresh and org toggle functionality --- .../platform/AssistantSelect.tsx | 255 ++++++++++-------- 1 file changed, 140 insertions(+), 115 deletions(-) diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index 4a81a2265..e0d88dc12 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -10,7 +10,11 @@ import { import { useContext, useEffect, useMemo, useRef } from "react"; import { useAuth } from "../../../context/Auth"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; -import { selectCurrentOrg, setSelectedProfile } from "../../../redux"; +import { + selectCurrentOrg, + setSelectedOrgId, + setSelectedProfile, +} from "../../../redux"; import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; import { fontSize, @@ -156,6 +160,7 @@ export default function AssistantSelect() { const buttonRef = useRef(null); const { selectedProfile, refreshProfiles } = useAuth(); const currentOrg = useAppSelector(selectCurrentOrg); + const orgs = useAppSelector((store) => store.profiles.organizations); const ideMessenger = useContext(IdeMessengerContext); const { isToolbarExpanded } = useLump(); @@ -216,6 +221,24 @@ export default function AssistantSelect() { }; }, [currentOrg, selectedProfile]); + const cycleOrgs = () => { + const orgIds = orgs.map((org) => org.id); + if (orgIds.length < 2) { + return; + } + let nextId = orgIds[0]; + if (currentOrg) { + const curIndex = orgIds.indexOf(currentOrg.id); + const nextIndex = (curIndex + 1) % orgIds.length; + nextId = orgIds[nextIndex]; + } + // Optimistic update + dispatch(setSelectedOrgId(nextId)); + ideMessenger.post("didChangeSelectedOrg", { + id: nextId, + }); + }; + const tinyFont = useFontSize(-4); const smallFont = useFontSize(-3); @@ -242,136 +265,138 @@ export default function AssistantSelect() { } return ( - <> - -
- -
-
- -
- - {selectedProfile.title} - + +
+ +
+
+
-
+
- - + + +
+ {profiles?.map((profile, idx) => { + return ( + + ); + })} +
+ +
- {profiles?.map((profile, idx) => { - return ( - - ); - })} -
+ className="my-0 h-[0.5px]" + style={{ + backgroundColor: vscCommandCenterInactiveBorder, + }} + /> -
-
- -
- login(false)} +
+ login(false)} + > +
-
- - New Assistant -
- -
- { - e.stopPropagation(); - refreshProfiles(); - buttonRef.current?.click(); - }} - /> + + New Assistant
-
- +
- -
{ + e.stopPropagation(); + refreshProfiles(); + buttonRef.current?.click(); }} > + + Refresh + +
+
+ +
+ +
+ + {getMetaKeyLabel()} ⇧ ' to toggle + +
+ {currentOrg?.iconUrl ? ( + + ) : ( + + )} + - {getMetaKeyLabel()} ⇧ ' to toggle + {currentOrg?.name || "Personal"} -
navigate(ROUTES.CONFIG)} - > - {currentOrg?.iconUrl ? ( - - ) : ( - - )} - - {currentOrg?.name || "Personal"} - -
- - -
- - - Refresh orgs/assistants - - +
+ + +
+ ); }