mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-27 21:08:00 +00:00
- Introduced `ActionableCard` component for rendering actionable insights with completion, snooze, and dismiss functionality. - Added `ChatModal` component to support AI-driven conversations, task execution, and real-time orchestration. - Implemented snooze portal, priority styling, and typing indicators to enhance UX. - Integrated WebSocket-based messaging and backend task execution with progress tracking.
67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
import type { ReactNode } from 'react';
|
|
import { createContext, useContext, useEffect } from 'react';
|
|
import { useDispatch } from 'react-redux';
|
|
|
|
import { useIntelligenceSocketManager } from '../hooks/useIntelligenceSocket';
|
|
import { setInitialized, setConnectionStatus } from '../store/intelligenceSlice';
|
|
|
|
/**
|
|
* Intelligence context for managing system-wide Intelligence state
|
|
*/
|
|
interface IntelligenceContextValue {
|
|
isInitialized: boolean;
|
|
isConnected: boolean;
|
|
initialize: () => void;
|
|
}
|
|
|
|
const IntelligenceContext = createContext<IntelligenceContextValue | null>(null);
|
|
|
|
interface IntelligenceProviderProps {
|
|
children: ReactNode;
|
|
}
|
|
|
|
/**
|
|
* Intelligence Provider - manages Intelligence system initialization and state
|
|
*/
|
|
export function IntelligenceProvider({ children }: IntelligenceProviderProps) {
|
|
const dispatch = useDispatch();
|
|
const socketManager = useIntelligenceSocketManager();
|
|
|
|
// Initialize Intelligence system
|
|
useEffect(() => {
|
|
dispatch(setInitialized(true));
|
|
dispatch(setConnectionStatus(socketManager.isConnected ? 'connected' : 'connecting'));
|
|
}, [dispatch, socketManager.isConnected]);
|
|
|
|
// Monitor connection status
|
|
useEffect(() => {
|
|
if (socketManager.isConnected) {
|
|
dispatch(setConnectionStatus('connected'));
|
|
} else {
|
|
dispatch(setConnectionStatus('connecting'));
|
|
}
|
|
}, [dispatch, socketManager.isConnected]);
|
|
|
|
const contextValue: IntelligenceContextValue = {
|
|
isInitialized: true,
|
|
isConnected: socketManager.isConnected,
|
|
initialize: socketManager.connect,
|
|
};
|
|
|
|
return (
|
|
<IntelligenceContext.Provider value={contextValue}>
|
|
{children}
|
|
</IntelligenceContext.Provider>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Hook to access Intelligence context
|
|
*/
|
|
export function useIntelligenceContext() {
|
|
const context = useContext(IntelligenceContext);
|
|
if (!context) {
|
|
throw new Error('useIntelligenceContext must be used within IntelligenceProvider');
|
|
}
|
|
return context;
|
|
} |