Fix authentication state consistency across components
- Fix ChatInterface to use context's reactive isAuthenticated value - Fix useAgentLoop to use context's reactive isAuthenticated value - Ensure consistent authentication state checking across the application - Add isAuthenticated to useCallback dependencies for proper reactivity 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
3a4a5cdc52
commit
aed7a25ea7
2 changed files with 4 additions and 4 deletions
|
|
@ -16,7 +16,7 @@ export function ChatInterface() {
|
|||
getAgentLoopState,
|
||||
} = useConversation();
|
||||
|
||||
const { currentProvider } = useInference();
|
||||
const { provider: currentProvider, isAuthenticated } = useInference();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ const DEFAULT_CONFIG: AgentLoopConfig = {
|
|||
|
||||
export function useAgentLoop(config: Partial<AgentLoopConfig> = {}): UseAgentLoopReturn {
|
||||
const finalConfig = { ...DEFAULT_CONFIG, ...config };
|
||||
const { currentProvider } = useInference();
|
||||
const { provider: currentProvider, isAuthenticated } = useInference();
|
||||
const { getAllTools, callTool: callMCPTool, connections } = useMCP();
|
||||
|
||||
// Track running loops
|
||||
|
|
@ -255,7 +255,7 @@ export function useAgentLoop(config: Partial<AgentLoopConfig> = {}): UseAgentLoo
|
|||
conversation: Conversation,
|
||||
onUpdate: (conversation: Conversation) => void
|
||||
) => {
|
||||
if (!currentProvider?.isAuthenticated) {
|
||||
if (!isAuthenticated || !currentProvider) {
|
||||
throw new Error('No authenticated inference provider available');
|
||||
}
|
||||
|
||||
|
|
@ -397,7 +397,7 @@ export function useAgentLoop(config: Partial<AgentLoopConfig> = {}): UseAgentLoo
|
|||
} finally {
|
||||
loopStates.current.delete(conversationId);
|
||||
}
|
||||
}, [currentProvider, finalConfig, toInferenceMessages, fromInferenceResponse, getAllTools, executeTool]);
|
||||
}, [isAuthenticated, currentProvider, finalConfig, toInferenceMessages, fromInferenceResponse, getAllTools, executeTool]);
|
||||
|
||||
const stopLoop = useCallback((conversationId: string) => {
|
||||
const loopState = loopStates.current.get(conversationId);
|
||||
|
|
|
|||
Loading…
Reference in a new issue