Merge pull request #6187 from uinstinct/assistant-loading-on-login

fix: show assistant loading after login
This commit is contained in:
Patrick Erichsen 2025-06-23 18:39:10 -07:00 • committed by GitHub
commit 5b7dd5c79d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 79 additions and 35 deletions

View file

@ -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 */}
<div className="flex gap-1.5 px-3 pb-1 pt-2">
<label className="text-vsc-foreground font-semibold">Assistants</label>
<div
className="flex cursor-pointer flex-row items-center gap-1 hover:brightness-125"
onClick={async (e) => {
e.stopPropagation();
setLoading(true);
await refreshProfiles();
setLoading(false);
}}
>
<ArrowPathIcon
className={cn(
"text-description h-2.5 w-2.5",
loading && "animate-spin-slow",
)}
/>
</div>
<div className="flex cursor-pointer flex-row items-center gap-1 hover:brightness-125"></div>
</div>
<div className="thin-scrollbar flex max-h-[300px] flex-col overflow-y-auto">

View file

@ -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 (
<ListboxButton
data-testid="assistant-select-button"
@ -20,14 +25,28 @@ export function SelectedAssistantButton({
style={{ fontSize: fontSize(-3) }}
>
<div className="flex flex-row items-center gap-1.5">
<div className="h-3 w-3 flex-shrink-0 select-none">
<AssistantIcon size={3} assistant={selectedProfile} />
</div>
<span
className={`line-clamp-1 select-none break-all ${isToolbarExpanded ? "xs:hidden sm:line-clamp-1" : ""}`}
>
{selectedProfile.title}
</span>
{configLoading ? (
<span className="text-description flex flex-row items-center">
<ArrowPathIcon
className={cn(
"text-description mr-1.5 h-3 w-3",
configLoading && "animate-spin-slow",
)}
/>
Loading
</span>
) : (
<>
<div className="h-3 w-3 flex-shrink-0 select-none">
<AssistantIcon size={3} assistant={selectedProfile} />
</div>
<span
className={`line-clamp-1 select-none break-all ${isToolbarExpanded ? "xs:hidden sm:line-clamp-1" : ""}`}
>
{selectedProfile.title}
</span>
</>
)}
</div>
<ChevronDownIcon
className="h-2 w-2 flex-shrink-0 select-none"

View file

@ -1,4 +1,4 @@
import { PlusIcon } from "@heroicons/react/24/outline";
import { ArrowPathIcon, PlusIcon } from "@heroicons/react/24/outline";
import { isOnPremSession } from "core/control-plane/AuthTypes";
import { useContext, useEffect, useRef } from "react";
import { useAuth } from "../../context/Auth";
@ -9,6 +9,7 @@ import {
setSelectedProfile,
} from "../../redux/slices/profilesSlice";
import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util";
import { cn } from "../../util/cn";
import { useLump } from "../mainInput/Lump/LumpContext";
import {
Listbox,
@ -28,8 +29,15 @@ export function AssistantAndOrgListbox() {
const currentOrg = useAppSelector(selectCurrentOrg);
const ideMessenger = useContext(IdeMessengerContext);
const { isToolbarExpanded } = useLump();
const { profiles, selectedProfile, session, login, organizations } =
useAuth();
const {
profiles,
selectedProfile,
session,
login,
organizations,
refreshProfiles,
} = useAuth();
const configLoading = useAppSelector((store) => store.config.loading);
const smallFont = useFontSize(-3);
const tinyFont = useFontSize(-4);
const shouldRenderOrgInfo =
@ -152,6 +160,30 @@ export function AssistantAndOrgListbox() {
</span>
</ListboxOption>
<ListboxOption
value="new-assistant"
fontSizeModifier={-2}
className="border-border border-b px-2 py-1.5"
onClick={session ? onNewAssistant : () => login(false)}
>
<span
className="text-description flex flex-row items-center"
style={{ fontSize: tinyFont }}
onClick={async (e) => {
e.stopPropagation();
await refreshProfiles();
}}
>
<ArrowPathIcon
className={cn(
"mr-1 h-3 w-3",
configLoading && "animate-spin-slow",
)}
/>
Reload config
</span>
</ListboxOption>
<AccountOption onClose={close} />
<div

View file

@ -12,6 +12,7 @@ import React, {
} from "react";
import { useWebviewListener } from "../hooks/useWebviewListener";
import { useAppDispatch, useAppSelector } from "../redux/hooks";
import { setConfigLoading } from "../redux/slices/configSlice";
import {
selectCurrentOrg,
selectSelectedProfile,
@ -94,17 +95,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]);

View file

@ -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],
);

View file

@ -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<boolean>) => {
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,