From 6b98dedb60ed1f081a2a06c695e2965924eac14f Mon Sep 17 00:00:00 2001 From: Charlie Bailey Date: Tue, 9 Jun 2026 14:26:41 -0700 Subject: [PATCH] fix to separate synthetic orchestrator persona from advisor registry which was throwing 400 error when not filtered out of registry. --- .../src/components/SettingsModal.js | 6 ++-- .../src/contexts/AppConfigContext.js | 32 +++++++++---------- phd-advisor-frontend/src/pages/ChatPage.js | 4 +-- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/phd-advisor-frontend/src/components/SettingsModal.js b/phd-advisor-frontend/src/components/SettingsModal.js index c0ee0bb..11aaa78 100644 --- a/phd-advisor-frontend/src/components/SettingsModal.js +++ b/phd-advisor-frontend/src/components/SettingsModal.js @@ -115,7 +115,7 @@ const SettingsModal = ({ const [message, setMessage] = useState(null); const [isSubmitting, setIsSubmitting] = useState(false); - const personaIds = useMemo(() => Object.keys(advisors || {}).filter(id => id !== 'aggregated'), [advisors]); + const personaIds = useMemo(() => Object.keys(advisors || {}), [advisors]); const [modelDraft, setModelDraft] = useState(() => { const fallback = llmConfig?.default_backend || availableBackends?.[0]; const seed = llmConfig?.persona_backends || {}; @@ -274,7 +274,7 @@ const SettingsModal = ({ }`, }); - const advisorEntries = Object.entries(advisors || {}).filter(([id]) => id !== 'aggregated'); + const advisorEntries = Object.entries(advisors || {}); const enabledCount = advisorEntries.filter(([id]) => isAdvisorEnabled(id)).length; const setAll = (enabled) => setAllAdvisorsEnabled(enabled); @@ -449,7 +449,7 @@ const SettingsModal = ({ {activeTab === 'model' && ( <> id !== 'aggregated'))} + advisors={advisors || {}} availableBackends={availableBackends || []} value={modelDraft} onChange={setModelDraft} diff --git a/phd-advisor-frontend/src/contexts/AppConfigContext.js b/phd-advisor-frontend/src/contexts/AppConfigContext.js index 7af428c..04edbd3 100644 --- a/phd-advisor-frontend/src/contexts/AppConfigContext.js +++ b/phd-advisor-frontend/src/contexts/AppConfigContext.js @@ -1,8 +1,21 @@ -import React, { createContext, useContext, useState, useEffect } from 'react'; +import React, { createContext, useContext, useState, useEffect, useMemo } from 'react'; import * as LucideIcons from 'lucide-react'; const AppConfigContext = createContext(null); +const SYNTHETIC_PERSONAS = { + aggregated: { + name: 'Orchestrator', + role: 'Synthesized Response', + description: 'A single combined response merging all advisor perspectives.', + color: '#7C3AED', + bgColor: '#F3E8FF', + darkColor: '#A78BFA', + darkBgColor: '#3B2A5E', + icon: LucideIcons.User, + }, +}; + const ADVISOR_PREFS_URL = `${process.env.REACT_APP_API_URL}/api/me/advisor-preferences`; // The frontend tracks disabled advisors as an object keyed by id @@ -137,19 +150,6 @@ export const AppConfigProvider = ({ children }) => { useEffect(() => { const built = buildAdvisors(personaItems, avatarOverrides); - // Synthetic persona used for aggregated/synthesized responses — represents - // a single combined "Partner" voice rather than the panel of advisors. - built.aggregated = { - name: 'Orchestrator', - role: 'Synthesized Response', - description: 'A single combined response merging all advisor perspectives.', - color: '#7C3AED', - bgColor: '#F3E8FF', - darkColor: '#A78BFA', - darkBgColor: '#3B2A5E', - icon: LucideIcons.User, - avatarUrl: avatarOverrides.aggregated || null, - }; setAdvisors(built); }, [personaItems, avatarOverrides]); @@ -273,8 +273,8 @@ export const AppConfigProvider = ({ children }) => { }, [config]); const getAdvisorColors = buildGetAdvisorColors(advisors); - const allPersonas = advisors; - const getAllPersonaColors = getAdvisorColors; + const allPersonas = useMemo(() => ({ ...advisors, ...SYNTHETIC_PERSONAS }), [advisors]); + const getAllPersonaColors = buildGetAdvisorColors(allPersonas); const value = { config, diff --git a/phd-advisor-frontend/src/pages/ChatPage.js b/phd-advisor-frontend/src/pages/ChatPage.js index 2e26c86..ee11425 100644 --- a/phd-advisor-frontend/src/pages/ChatPage.js +++ b/phd-advisor-frontend/src/pages/ChatPage.js @@ -919,9 +919,7 @@ const handleNewChat = async (sessionId = null) => {
id !== 'aggregated') - )} + advisors={advisors} thinkingAdvisors={thinkingAdvisors} getAdvisorColors={getAdvisorColors} isDark={isDark}