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,