diff --git a/web/src/app/admin/assistants/AssistantEditor.tsx b/web/src/app/admin/assistants/AssistantEditor.tsx index 6fe9301a7aa..c3f3eb5dfcf 100644 --- a/web/src/app/admin/assistants/AssistantEditor.tsx +++ b/web/src/app/admin/assistants/AssistantEditor.tsx @@ -412,7 +412,9 @@ export function AssistantEditor({ }); } } + await refreshAssistants(); + console.log("redirectType", redirectType); router.push( redirectType === SuccessfulPersonaUpdateRedirectType.ADMIN ? `/admin/assistants?u=${Date.now()}` diff --git a/web/src/components/context/AssistantsContext.tsx b/web/src/components/context/AssistantsContext.tsx index 4c389240266..2e40cb5bf44 100644 --- a/web/src/components/context/AssistantsContext.tsx +++ b/web/src/components/context/AssistantsContext.tsx @@ -81,34 +81,36 @@ export const AssistantsProvider: React.FC<{ checkImageGenerationAvailability(); }, []); - useEffect(() => { - const fetchPersonas = async () => { - if (!isAdmin && !isCurator) { - return; - } + const fetchPersonas = async () => { + if (!isAdmin && !isCurator) { + return; + } - try { - const [editableResponse, allResponse] = await Promise.all([ - fetch("/api/admin/persona?get_editable=true"), - fetch("/api/admin/persona"), - ]); - - if (editableResponse.ok) { - const editablePersonas = await editableResponse.json(); - setEditablePersonas(editablePersonas); - } + try { + const [editableResponse, allResponse] = await Promise.all([ + fetch("/api/admin/persona?get_editable=true"), + fetch("/api/admin/persona"), + ]); + + if (editableResponse.ok) { + const editablePersonas = await editableResponse.json(); + setEditablePersonas(editablePersonas); + } - if (allResponse.ok) { - const allPersonas = await allResponse.json(); - setAllAssistants(allPersonas); - } else { - console.error("Error fetching personas:", allResponse); - } - } catch (error) { - console.error("Error fetching personas:", error); + if (allResponse.ok) { + console.log("allResponse", allResponse); + const allPersonas = await allResponse.json(); + setAllAssistants(allPersonas); + console.log("allAssistants", allAssistants); + } else { + console.error("Error fetching personas:", allResponse); } - }; + } catch (error) { + console.error("Error fetching personas:", error); + } + }; + useEffect(() => { fetchPersonas(); }, [isAdmin, isCurator]); @@ -144,6 +146,7 @@ export const AssistantsProvider: React.FC<{ }); if (!response.ok) throw new Error("Failed to fetch assistants"); let assistants: Persona[] = await response.json(); + if (!hasImageCompatibleModel) { assistants = assistants.filter( (assistant) => @@ -152,15 +155,21 @@ export const AssistantsProvider: React.FC<{ ) ); } + if (!hasAnyConnectors) { assistants = assistants.filter( (assistant) => assistant.num_chunks === 0 ); } + setAssistants(assistants); + + // Fetch and update allAssistants for admins and curators + await fetchPersonas(); } catch (error) { console.error("Error refreshing assistants:", error); } + setRecentAssistants( assistants.filter( (assistant) =>