feat: enhance OllaHub with new features and UI improvements

- Introduced a comprehensive README.md detailing the application, its architecture, and key features.
- Implemented a local-first architecture with deep research capabilities, including query decomposition and parallel web scraping.
- Added a reactive UI built with React and Next.js, featuring Tailwind CSS for styling and Zustand for state management.
- Integrated a task scheduler for recurring tasks and system monitoring for real-time resource management.
- Enhanced settings page with debug mode options and improved hardware dashboard loading states.
- Updated chat interface to include debug data visualization and improved user experience during message streaming.
- Removed unused favicon and updated application icons for better branding.
- Improved navigation handling with non-blocking transitions and state management for setup completion.
This commit is contained in:
Evandro Fonseca Junior committed 2025-11-28 15:15:38 -03:00
1 parent 55749c07e3
commit c7da6cb8a8
36 files changed
+1458 -293

No files matched your search

+111
View File
@@ -0,0 +1,111 @@
import { useState, useEffect } from 'react';
import { invoke } from '@tauri-apps/api/core';
import { useOllamaCheck, type OllamaStatus } from './use-ollama-check';
export type SetupStatus = 'checking' | 'ready' | 'needs_setup' | 'needs_ollama';
export function useSetupCheck() {
const { status: ollamaStatus, check: checkOllama } = useOllamaCheck();
const [setupStatus, setSetupStatus] = useState<SetupStatus>('checking');
const [checkingStep, setCheckingStep] = useState<string>('Verificando Ollama...');
const [hasModels, setHasModels] = useState(false);
const [modelsCount, setModelsCount] = useState(0);
const checkModels = async (): Promise<boolean> => {
try {
setCheckingStep('Verificando modelos instalados...');
const models = await invoke<Array<{ name: string; size: string; id: string; modified_at: string }>>('list_local_models');
const count = models.length;
setModelsCount(count);
const hasAny = count > 0;
setHasModels(hasAny);
return hasAny;
} catch (error) {
console.error('Failed to check models:', error);
// Em caso de erro, assumir que não há modelos (seguro)
setHasModels(false);
setModelsCount(0);
return false;
}
};
const determineSetupStatus = async (ollamaStatus: OllamaStatus): Promise<SetupStatus> => {
// Se Ollama não está instalado, precisa instalar
if (ollamaStatus === 'not_installed') {
return 'needs_ollama';
}
// Se Ollama está instalado mas parado, tentar iniciar primeiro
if (ollamaStatus === 'installed_stopped') {
try {
setCheckingStep('Iniciando Ollama...');
await invoke('auto_start_ollama');
// Aguardar um pouco para o servidor iniciar
await new Promise(resolve => setTimeout(resolve, 2000));
// Verificar novamente se está rodando
const running = await invoke<boolean>('check_ollama_running');
if (!running) {
// Ainda não está rodando, precisa de intervenção do usuário
return 'needs_setup';
}
// Agora está rodando, verificar modelos
const hasAnyModels = await checkModels();
return hasAnyModels ? 'ready' : 'needs_setup';
} catch (error) {
console.error('Failed to auto-start Ollama:', error);
return 'needs_setup';
}
}
// Se Ollama está rodando, verificar modelos
if (ollamaStatus === 'running') {
const hasAnyModels = await checkModels();
return hasAnyModels ? 'ready' : 'needs_setup';
}
// Estado checking ou qualquer outro caso
return 'checking';
};
useEffect(() => {
const performCheck = async () => {
if (ollamaStatus === 'checking') {
setSetupStatus('checking');
setCheckingStep('Verificando Ollama...');
return;
}
const status = await determineSetupStatus(ollamaStatus);
setSetupStatus(status);
if (status === 'ready') {
setCheckingStep('Tudo pronto!');
} else if (status === 'needs_setup') {
setCheckingStep('Configuração necessária');
} else if (status === 'needs_ollama') {
setCheckingStep('Ollama não instalado');
}
};
performCheck();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ollamaStatus]);
const recheck = async () => {
setSetupStatus('checking');
setCheckingStep('Verificando Ollama...');
await checkOllama();
// O useEffect vai processar o novo status
};
return {
status: setupStatus,
ollamaStatus,
hasModels,
modelsCount,
checkingStep,
recheck,
};
}