🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix: slove the agent details pages not get the agent config always lo… (#13772)
LiJianf89adb36b344
diff --git a/src/hooks/useInitAgentConfig.ts b/src/hooks/useInitAgentConfig.tsindex c0a2ae080e5..bd95268a273 100644--- a/src/hooks/useInitAgentConfig.ts+++ b/src/hooks/useInitAgentConfig.ts@@ -18,7 +18,8 @@ export const useInitAgentConfig = (agentId?: string) => {const params = useParams<{ aid?: string }>();- const id = agentId || activeAgentId || params.aid || '';+ // Prioritize URL params over store's activeAgentId to avoid stale ID from previous navigation+ const id = agentId || params.aid || activeAgentId || '';const data = useFetchAgentConfig(isLogin, id);diff --git a/src/store/agent/slices/agent/action.ts b/src/store/agent/slices/agent/action.tsindex c284a730ef2..dbcb8d891b2 100644--- a/src/store/agent/slices/agent/action.ts+++ b/src/store/agent/slices/agent/action.ts@@ -8,7 +8,7 @@ import type { SWRResponse } from 'swr';import type { PartialDeep } from 'type-fest';import { MESSAGE_CANCEL_FLAT } from '@/const/message';-import { mutate, useClientDataSWR, useClientDataSWRWithSync } from '@/libs/swr';+import { mutate, useClientDataSWRWithSync } from '@/libs/swr';import type { CreateAgentParams, CreateAgentResult } from '@/services/agent';import { agentService } from '@/services/agent';import {@@ -270,19 +270,21 @@ export class AgentSliceActionImpl {isLogin: boolean | undefined,agentId: string,): SWRResponse<LobeAgentConfig> => {- return useClientDataSWR<LobeAgentConfig>(- // Only fetch when login status is explicitly true (not null/undefined)+ const swrKey =isLogin === true && agentId && !isChatGroupSessionId(agentId)? ([FETCH_AGENT_CONFIG_KEY, agentId] as const)- : null,- async ([, id]: readonly [string, string]) => {- const data = await agentService.getAgentConfigById(id);+ : null;++ return useClientDataSWRWithSync<LobeAgentConfig>(+ swrKey,+ async () => {+ const data = await agentService.getAgentConfigById(agentId);return data as LobeAgentConfig;},{- onSuccess: (data) => {+ onData: (data) => {+ if (!data) return;this.#get().internal_dispatchAgentMap(agentId, data);-this.#set({ activeAgentId: data.id }, false, 'fetchAgentConfig');},},