From ec32afcc544218d176cca87caa3fd50803b6830d Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Wed, 18 Jun 2025 17:21:56 +0530 Subject: [PATCH 1/5] fix: show assistant loading on login --- .../modelSelection/platform/AssistantSelect.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index aebae2aa6..ac4a06553 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -32,6 +32,7 @@ import { import type { ProfileDescription } from "core/config/ConfigHandler"; import { useNavigate } from "react-router-dom"; +import { useWebviewListener } from "../../../hooks/useWebviewListener"; import { cn } from "../../../util/cn"; import { ROUTES } from "../../../util/navigation"; import { useLump } from "../../mainInput/Lump/LumpContext"; @@ -171,6 +172,11 @@ export default function AssistantSelect() { }); close(); } + async function refreshProfilesWithLoading() { + setLoading(true); + await refreshProfiles(); + setLoading(false); + } useEffect(() => { let lastToggleTime = 0; @@ -213,6 +219,8 @@ export default function AssistantSelect() { }; }, [currentOrg, selectedProfile]); + useWebviewListener("sessionUpdate", refreshProfilesWithLoading, []); + const cycleOrgs = () => { if (!session) { void login(false); @@ -294,10 +302,9 @@ export default function AssistantSelect() { className="flex cursor-pointer flex-row items-center gap-1 hover:brightness-125" onClick={async (e) => { e.stopPropagation(); - setLoading(true); - await refreshProfiles(); - setLoading(false); - buttonRef.current?.click(); + refreshProfilesWithLoading().then(() => + buttonRef.current?.click(), + ); }} > Date: Thu, 19 Jun 2025 10:12:24 +0530 Subject: [PATCH 2/5] show a loading indicator --- .../platform/AssistantSelect.tsx | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index ac4a06553..c33f4c707 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -279,14 +279,20 @@ export default function AssistantSelect() { style={{ fontSize: fontSize(-3) }} >
-
- -
- - {selectedProfile.title} - + {!loading ? ( + loading... + ) : ( + <> +
+ +
+ + {selectedProfile.title} + + + )}
{ e.stopPropagation(); - refreshProfilesWithLoading().then(() => + void refreshProfilesWithLoading().then(() => buttonRef.current?.click(), ); }} @@ -310,7 +316,7 @@ export default function AssistantSelect() { From afb36cdbfdbfdd0d4cc5e220252f90fc12d83490 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 19 Jun 2025 11:33:47 +0530 Subject: [PATCH 3/5] `configLoading` redux state on initial load, login and manual config refresh show the loading indicator --- .../platform/AssistantSelect.tsx | 22 +++++-------------- gui/src/context/Auth.tsx | 7 +++++- gui/src/hooks/ParallelListeners.tsx | 6 +++-- gui/src/redux/slices/configSlice.ts | 8 ++++++- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index c33f4c707..1a7c82c36 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -7,7 +7,7 @@ import { ExclamationTriangleIcon, PlusIcon, } from "@heroicons/react/24/outline"; -import { useContext, useEffect, useMemo, useRef, useState } from "react"; +import { useContext, useEffect, useMemo, useRef } from "react"; import { useAuth } from "../../../context/Auth"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { @@ -32,7 +32,6 @@ import { import type { ProfileDescription } from "core/config/ConfigHandler"; import { useNavigate } from "react-router-dom"; -import { useWebviewListener } from "../../../hooks/useWebviewListener"; import { cn } from "../../../util/cn"; import { ROUTES } from "../../../util/navigation"; import { useLump } from "../../mainInput/Lump/LumpContext"; @@ -156,7 +155,7 @@ export default function AssistantSelect() { const orgs = useAppSelector((store) => store.profiles.organizations); const ideMessenger = useContext(IdeMessengerContext); const { isToolbarExpanded } = useLump(); - const [loading, setLoading] = useState(false); + const configLoading = useAppSelector((store) => store.config.loading); const { profiles, session, login, selectedProfile, refreshProfiles } = useAuth(); @@ -172,11 +171,6 @@ export default function AssistantSelect() { }); close(); } - async function refreshProfilesWithLoading() { - setLoading(true); - await refreshProfiles(); - setLoading(false); - } useEffect(() => { let lastToggleTime = 0; @@ -219,8 +213,6 @@ export default function AssistantSelect() { }; }, [currentOrg, selectedProfile]); - useWebviewListener("sessionUpdate", refreshProfilesWithLoading, []); - const cycleOrgs = () => { if (!session) { void login(false); @@ -279,7 +271,7 @@ export default function AssistantSelect() { style={{ fontSize: fontSize(-3) }} >
- {!loading ? ( + {configLoading ? ( loading... ) : ( <> @@ -306,17 +298,15 @@ export default function AssistantSelect() { Assistants
{ + onClick={(e) => { e.stopPropagation(); - void refreshProfilesWithLoading().then(() => - buttonRef.current?.click(), - ); + void refreshProfiles().then(() => buttonRef.current?.click()); }} >
diff --git a/gui/src/context/Auth.tsx b/gui/src/context/Auth.tsx index 8c928630d..143f09f5f 100644 --- a/gui/src/context/Auth.tsx +++ b/gui/src/context/Auth.tsx @@ -19,6 +19,7 @@ import { setSelectedOrgId, } from "../redux/"; import { useAppDispatch, useAppSelector } from "../redux/hooks"; +import { setConfigLoading } from "../redux/slices/configSlice"; import { setDialogMessage, setShowDialog } from "../redux/slices/uiSlice"; import { IdeMessengerContext } from "./IdeMessenger"; @@ -53,7 +54,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ const login: AuthContextType["login"] = (useOnboarding: boolean) => { return new Promise((resolve) => { - ideMessenger + void ideMessenger .request("getControlPlaneSessionInfo", { silent: false, useOnboarding, @@ -113,17 +114,21 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ "sessionUpdate", async (data) => { setSession(data.sessionInfo); + void refreshProfiles(); }, [], ); const refreshProfiles = useCallback(async () => { try { + dispatch(setConfigLoading(true)); await ideMessenger.request("config/refreshProfiles", undefined); ideMessenger.post("showToast", ["info", "Config refreshed"]); } catch (e) { console.error("Failed to refresh profiles", e); ideMessenger.post("showToast", ["error", "Failed to refresh config"]); + } finally { + dispatch(setConfigLoading(false)); } }, [ideMessenger]); diff --git a/gui/src/hooks/ParallelListeners.tsx b/gui/src/hooks/ParallelListeners.tsx index 155b91e2c..0f3f56a62 100644 --- a/gui/src/hooks/ParallelListeners.tsx +++ b/gui/src/hooks/ParallelListeners.tsx @@ -12,7 +12,7 @@ import { } from "../redux"; import { useAppDispatch, useAppSelector } from "../redux/hooks"; import { selectCurrentToolCallApplyState } from "../redux/selectors/selectCurrentToolCall"; -import { setConfigResult } from "../redux/slices/configSlice"; +import { setConfigLoading, setConfigResult } from "../redux/slices/configSlice"; import { setLastNonEditSessionEmpty, updateEditStateApplyState, @@ -93,6 +93,7 @@ function ParallelListeners() { const initialLoadAuthAndConfig = useCallback( async (initial: boolean) => { + dispatch(setConfigLoading(true)); const result = await ideMessenger.request( "config/getSerializedProfileInfo", undefined, @@ -100,6 +101,7 @@ function ParallelListeners() { if (result.status === "success") { await handleConfigUpdate(initial, result.content); } + dispatch(setConfigLoading(false)); }, [ideMessenger, handleConfigUpdate], ); @@ -242,7 +244,7 @@ function ParallelListeners() { dispatch(updateEditStateApplyState(state)); if (state.status === "closed") { - dispatch(exitEdit({})); + void dispatch(exitEdit({})); } } else { // chat or agent diff --git a/gui/src/redux/slices/configSlice.ts b/gui/src/redux/slices/configSlice.ts index b26d596c8..8d48f7332 100644 --- a/gui/src/redux/slices/configSlice.ts +++ b/gui/src/redux/slices/configSlice.ts @@ -6,6 +6,7 @@ import { DEFAULT_MAX_TOKENS } from "core/llm/constants"; export type ConfigState = { configError: ConfigValidationError[] | undefined; config: BrowserSerializedContinueConfig; + loading: boolean; }; export const EMPTY_CONFIG: BrowserSerializedContinueConfig = { @@ -47,6 +48,7 @@ export const EMPTY_CONFIG: BrowserSerializedContinueConfig = { const initialState: ConfigState = { configError: undefined, config: EMPTY_CONFIG, + loading: false, }; export const configSlice = createSlice({ @@ -82,6 +84,9 @@ export const configSlice = createSlice({ ) => { state.config = config; }, + setConfigLoading: (state, { payload: loading }: PayloadAction) => { + state.loading = loading; + }, }, selectors: { selectSelectedChatModelContextLength: (state): number => { @@ -99,7 +104,8 @@ export const configSlice = createSlice({ }, }); -export const { updateConfig, setConfigResult } = configSlice.actions; +export const { updateConfig, setConfigResult, setConfigLoading } = + configSlice.actions; export const { selectSelectedChatModelContextLength, From 99d32fe12d203ed3b7b97ffac89ac674da6bf6df Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 19 Jun 2025 11:33:56 +0530 Subject: [PATCH 4/5] show loading in account selection --- gui/src/pages/config/AccountButton.tsx | 27 ++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/gui/src/pages/config/AccountButton.tsx b/gui/src/pages/config/AccountButton.tsx index 06c6beba0..a5c59f889 100644 --- a/gui/src/pages/config/AccountButton.tsx +++ b/gui/src/pages/config/AccountButton.tsx @@ -1,3 +1,4 @@ +import { ArrowPathIcon } from "@heroicons/react/24/outline"; import { UserCircleIcon } from "@heroicons/react/24/solid"; import { isOnPremSession } from "core/control-plane/AuthTypes"; import { @@ -10,11 +11,13 @@ import { Button } from "../../components/ui/Button"; import { useAuth } from "../../context/Auth"; import { selectCurrentOrg } from "../../redux"; import { useAppSelector } from "../../redux/hooks"; +import { cn } from "../../util/cn"; import { ScopeSelect } from "./ScopeSelect"; export function AccountButton() { - const { session, logout, login, organizations } = useAuth(); + const { session, logout, login, organizations, refreshProfiles } = useAuth(); const selectedOrg = useAppSelector(selectCurrentOrg); + const configLoading = useAppSelector((store) => store.config.loading); if (!session) { return ( @@ -58,9 +61,25 @@ export function AccountButton() { {organizations.length > 0 && (
- +
+ +
{ + e.stopPropagation(); + await refreshProfiles(); + }} + > + +
+
)} From 8fe7ad280b805fb526819f19abdd96e4b1c945d8 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Mon, 23 Jun 2025 17:30:32 -0700 Subject: [PATCH 5/5] feat: handle merge conflicts --- .../AssistantOptions.tsx | 24 +----------- .../SelectedAssistantButton.tsx | 35 +++++++++++++---- .../AssistantAndOrgListbox/index.tsx | 38 +++++++++++++++++-- 3 files changed, 64 insertions(+), 33 deletions(-) diff --git a/gui/src/components/AssistantAndOrgListbox/AssistantOptions.tsx b/gui/src/components/AssistantAndOrgListbox/AssistantOptions.tsx index 869aa5c67..23c54184d 100644 --- a/gui/src/components/AssistantAndOrgListbox/AssistantOptions.tsx +++ b/gui/src/components/AssistantAndOrgListbox/AssistantOptions.tsx @@ -1,7 +1,4 @@ -import { ArrowPathIcon } from "@heroicons/react/24/outline"; -import { useState } from "react"; import { useAuth } from "../../context/Auth"; -import { cn } from "../../util/cn"; import { AssistantOption } from "./AssistantOption"; interface AssistantOptionsProps { @@ -13,30 +10,13 @@ export function AssistantOptions({ selectedProfileId, onClose, }: AssistantOptionsProps) { - const [loading, setLoading] = useState(false); - const { profiles, refreshProfiles } = useAuth(); + const { profiles } = useAuth(); return ( <> - {/* Assistants Section Header */}
-
{ - e.stopPropagation(); - setLoading(true); - await refreshProfiles(); - setLoading(false); - }} - > - -
+
diff --git a/gui/src/components/AssistantAndOrgListbox/SelectedAssistantButton.tsx b/gui/src/components/AssistantAndOrgListbox/SelectedAssistantButton.tsx index 131f0d1e1..bb0a301e1 100644 --- a/gui/src/components/AssistantAndOrgListbox/SelectedAssistantButton.tsx +++ b/gui/src/components/AssistantAndOrgListbox/SelectedAssistantButton.tsx @@ -1,6 +1,9 @@ import { ChevronDownIcon } from "@heroicons/react/24/outline"; +import { ArrowPathIcon } from "@heroicons/react/24/solid"; import type { ProfileDescription } from "core/config/ConfigHandler"; +import { useAppSelector } from "../../redux/hooks"; import { fontSize } from "../../util"; +import { cn } from "../../util/cn"; import { useLump } from "../mainInput/Lump/LumpContext"; import { ListboxButton } from "../ui"; import { AssistantIcon } from "./AssistantIcon"; @@ -13,6 +16,8 @@ export function SelectedAssistantButton({ selectedProfile, }: SelectedAssistantButtonProps) { const { isToolbarExpanded } = useLump(); + const configLoading = useAppSelector((store) => store.config.loading); + return (
-
- -
- - {selectedProfile.title} - + {configLoading ? ( + + + Loading + + ) : ( + <> +
+ +
+ + {selectedProfile.title} + + + )}
store.config.loading); const smallFont = useFontSize(-3); const tinyFont = useFontSize(-4); const shouldRenderOrgInfo = @@ -152,6 +160,30 @@ export function AssistantAndOrgListbox() { + login(false)} + > + { + e.stopPropagation(); + await refreshProfiles(); + }} + > + + Reload config + + +