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 + + +
= ({ "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 8d0fef86d..5bf2c977a 100644 --- a/gui/src/hooks/ParallelListeners.tsx +++ b/gui/src/hooks/ParallelListeners.tsx @@ -5,7 +5,7 @@ import { EDIT_MODE_STREAM_ID } from "core/edit/constants"; import { FromCoreProtocol } from "core/protocol"; 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, @@ -100,6 +100,7 @@ function ParallelListeners() { const initialLoadAuthAndConfig = useCallback( async (initial: boolean) => { + dispatch(setConfigLoading(true)); const result = await ideMessenger.request( "config/getSerializedProfileInfo", undefined, @@ -107,6 +108,7 @@ function ParallelListeners() { if (result.status === "success") { await handleConfigUpdate(initial, result.content); } + dispatch(setConfigLoading(false)); }, [ideMessenger, handleConfigUpdate], ); 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,