Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(home): fetch agent config so knowledge toggles reflect in UI (#14834)

Arvin Xu8c4fbf4a81df
diff --git a/src/routes/(main)/home/features/InputArea/index.tsx b/src/routes/(main)/home/features/InputArea/index.tsx
index e180cb27bba..342ae20e7b3 100644
--- a/src/routes/(main)/home/features/InputArea/index.tsx
+++ b/src/routes/(main)/home/features/InputArea/index.tsx
@@ -5,6 +5,7 @@ import DragUploadZone, { useUploadFiles } from '@/components/DragUploadZone';
import { type ActionKeys } from '@/features/ChatInput';
import { ChatInputProvider, DesktopChatInput } from '@/features/ChatInput';
import { useHomeDailyBrief } from '@/hooks/useHomeDailyBrief';
+import { useInitAgentConfig } from '@/hooks/useInitAgentConfig';
import { useAgentStore } from '@/store/agent';
import { agentByIdSelectors } from '@/store/agent/selectors';
import { builtinAgentSelectors } from '@/store/agent/selectors/builtinAgentSelectors';
@@ -27,6 +28,17 @@ type BannerKind = 'skill' | 'botIntegration' | 'messenger';
const InputArea = () => {
const { loading, send, agentId } = useSend();
+ // Subscribe to the SWR key so `internal_refreshAgentConfig`'s `mutate(...)`
+ // has a listener after toggleFile / toggleKnowledgeBase — otherwise the
+ // Library submenu doesn't reflect server-side toggles. Pass `agentId`
+ // explicitly so AgentSelect switches refetch too.
+ useInitAgentConfig(agentId);
+ // Use the "config absent from agentMap" loading shape (same as Memory /
+ // Search / History) instead of SWR's `isLoading`, which would flash on
+ // every mount-time revalidation even when inbox data is already cached.
+ const isAgentConfigLoading = useAgentStore((s) =>
+ agentByIdSelectors.isAgentConfigLoadingById(agentId ?? '')(s),
+ );
const inboxAgentId = useAgentStore(builtinAgentSelectors.inboxAgentId);
const isLobehubSkillEnabled = useServerConfigStore(serverConfigSelectors.enableLobehubSkill);
const isKlavisEnabled = useServerConfigStore(serverConfigSelectors.enableKlavis);
@@ -134,7 +146,7 @@ const InputArea = () => {
useChatStore.setState({ mainInputEditor: instance });
}}
sendButtonProps={{
- disabled: loading,
+ disabled: loading || isAgentConfigLoading,
generating: loading,
onStop: () => {},
shape: 'round',