diff --git a/client/src/Providers/AgentsMapContext.tsx b/client/src/Providers/AgentsMapContext.tsx index e86c188aaf3..fcf666203d2 100644 --- a/client/src/Providers/AgentsMapContext.tsx +++ b/client/src/Providers/AgentsMapContext.tsx @@ -1,8 +1,29 @@ import { createContext, useContext } from 'react'; -import useAgentsMap from '~/hooks/Agents/useAgentsMap'; +import type { ReactNode } from 'react'; +import useAgentsMap, { useAgentsCatalog } from '~/hooks/Agents/useAgentsMap'; type AgentsMapContextType = ReturnType; /** Defaults to undefined (map unknown): an `{}` default outside the provider would * read as a loaded-but-empty catalog and misclassify stored agent picks as deleted. */ export const AgentsMapContext = createContext(undefined); export const useAgentsMapContext = () => useContext(AgentsMapContext); + +/** Separate lifecycle keeps the incremental map and its existing consumers compatible. */ +export const AgentsCatalogPendingContext = createContext(undefined); +export const useAgentsCatalogPending = () => useContext(AgentsCatalogPendingContext); + +/** One Root-owned catalog observer; existing readers still receive the incremental map. */ +export function AgentCatalogProvider({ + isAuthenticated, + children, +}: { + isAuthenticated: boolean; + children: ReactNode; +}) { + const { agentsMap, pending } = useAgentsCatalog({ isAuthenticated }); + return ( + + {children} + + ); +} diff --git a/client/src/Providers/ChatHostContext.tsx b/client/src/Providers/ChatHostContext.tsx index 310e9535072..3836b4a2bc5 100644 --- a/client/src/Providers/ChatHostContext.tsx +++ b/client/src/Providers/ChatHostContext.tsx @@ -11,6 +11,7 @@ import { } from '~/data-provider'; import { agentQueuedTurnsQueryKey } from '~/data-provider/SSE/queuedTurns'; import { useChatSettings } from '~/Providers/ChatSettingsContext'; +import useTurnReadiness from '~/hooks/Chat/ask/readiness'; import useTurnServices from '~/hooks/Chat/services'; import useNewConvo from '~/hooks/useNewConvo'; @@ -114,6 +115,11 @@ export const appChatHost: ChatHost = { usePaneConversation: (index) => useChatSettings().usePaneConversationState(index), useNewConversation: (index) => useNewConvo(index).newConversation, useTurnServices, + useTurnReadiness: (conversation, enabled) => { + const { config } = useChatSettings(); + const readiness = useTurnReadiness(conversation, enabled); + return config.loaded === false ? 'pending' : readiness; + }, /** `mutateAsync` is bound once per observer; the mutation result object is fresh every * render and would defeat the contract's memo. */ useAbortStream: () => useAbortStreamMutation().mutateAsync, diff --git a/client/src/components/Chat/Presentation.test.tsx b/client/src/components/Chat/Presentation.test.tsx index 513f1d8aa61..4031c0c2551 100644 --- a/client/src/components/Chat/Presentation.test.tsx +++ b/client/src/components/Chat/Presentation.test.tsx @@ -12,6 +12,7 @@ import { sideChatAvailableAtom, } from '@librechat/chat/react'; import type { TConversation, TStartupConfig } from 'librechat-data-provider'; +import type { SideChat } from '@librechat/chat/react'; import type { JotaiStore } from 'test/harness'; import type { Artifact } from '~/common'; import { prepareUndockedDocument } from '~/components/Artifacts/undockedWindow'; @@ -39,6 +40,7 @@ const mockOpenChildLabel = 'Open Child Activity'; const mockSideChatLabel = 'Side chat loaded'; const mockOpenSideChatLabel = 'Open Side Chat'; const mockAskSideChatLabel = 'Ask for a side chat'; +let mockSideChatProps: { chat: SideChat; onHandedTextTaken: (expected: SideChat) => void }; const mockSelectAgentConversationLabel = 'Select Agent Conversation'; const mockStartAgentRunLabel = 'Start Agent Run'; /** @@ -86,7 +88,8 @@ jest.mock('@librechat/chat/components', () => { ), loadSideChatPanel: () => Promise.resolve({ - default: function MockSideChatPanel() { + default: function MockSideChatPanel(props: typeof mockSideChatProps) { + mockSideChatProps = props; const parent = useParentSubagents(); return (