Files
OllaHub/hooks/use-system-monitor.ts
T
Evandro Fonseca Junior b2a06ed994 fix: address issues in model pull and chat API
- Refactored model pull logic to improve error handling and user feedback.
- Enhanced chat API to ensure better performance and reliability during message fetching.
- Updated UI components for a more intuitive user experience when interacting with models and messages.
2025-11-19 00:01:14 -03:00

30 lines
642 B
TypeScript

import { useState, useEffect } from 'react';
import { invoke } from '@tauri-apps/api/core';
import { listen } from '@tauri-apps/api/event';
export interface SystemStats {
cpu_usage: number;
memory_used: number;
memory_total: number;
}
export function useSystemMonitor() {
const [stats, setStats] = useState<SystemStats | null>(null);
useEffect(() => {
// Start the monitor thread in backend
invoke('start_system_monitor');
const unlisten = listen<SystemStats>('system-stats', (event) => {
setStats(event.payload);
});
return () => {
unlisten.then(f => f());
};
}, []);
return stats;
}