Files
leocrm/app/plugins/builtins/ai_proactive/frontend/SuggestionSidebar.tsx
T
Agent Zero 8cebb4f4e9 feat: unified_search + ai_proactive plugins with Ollama Cloud DeepSeek V4
- unified_search: Hybride Suche (PostgreSQL FTS + pgvector + RRF Fusion)
  - 5 Search Providers (Contact, Company, Mail, File, Event)
  - KI Query Understanding (Fuzzy, Facetten via LiteLLM)
  - DMS Text-Extraction (PDF, DOCX, XLSX, PPTX)
  - Embedding Pipeline (ollama/nomic-embed-text, 768 Dim)
  - Background Jobs für Indexierung
  - Plugin-basierte Provider Registry

- ai_proactive: Proaktiver KI-Agent
  - Context-Tracking (Frontend → Backend → Event Bus)
  - Proactive Engine mit LLM Suggestion-Generierung
  - SSE Real-time Push an Frontend
  - 6 AI Tools für Tool Registry
  - Rate-Limiting + User Settings
  - Deep Analysis Background Jobs

- Frontend Integration:
  - useAIContext Hook, SuggestionSidebar, SuggestionBadge
  - ProactiveAISettings Page, Search API Client
  - Globale Suche auf neue API umgestellt

- Tests: test_unified_search.py + test_ai_proactive.py (alle bestanden)
- Config: Ollama Cloud DeepSeek V4 als Default, konfigurierbar
- Dependencies: PyMuPDF, python-docx, python-pptx, pgvector
- Bugfixes: notification type_key length, migration IF NOT EXISTS
2026-07-18 11:21:51 +02:00

110 lines
3.5 KiB
TypeScript

import { useState } from 'react';
import { useSuggestions } from './api';
import { SuggestionCard } from './SuggestionCard';
interface SuggestionSidebarProps {
isOpen: boolean;
onClose: () => void;
}
export function SuggestionSidebar({ isOpen, onClose }: SuggestionSidebarProps) {
const { suggestions, connected, dismiss, act } = useSuggestions();
const [filter, setFilter] = useState<string>('all');
const filteredSuggestions = filter === 'all'
? suggestions
: suggestions.filter(s => s.suggestion_type === filter);
const filterOptions = [
{ value: 'all', label: 'Alle' },
{ value: 'info', label: 'Info' },
{ value: 'warning', label: 'Warnung' },
{ value: 'action', label: 'Aktion' },
{ value: 'insight', label: 'Erkenntnis' },
];
return (
<>
{/* Overlay */}
{isOpen && (
<div
className="fixed inset-0 bg-black/20 z-40 lg:hidden"
onClick={onClose}
/>
)}
{/* Sidebar */}
<aside
className={`fixed right-0 top-0 h-full w-96 bg-white shadow-2xl z-50 transform transition-transform duration-300 flex flex-col ${
isOpen ? 'translate-x-0' : 'translate-x-full'
}`}
>
{/* Header */}
<div className="flex items-center justify-between p-4 border-b border-gray-200">
<div className="flex items-center gap-2">
<h2 className="font-semibold text-gray-800">KI Vorschläge</h2>
{connected && (
<span className="flex items-center gap-1 text-xs text-green-600">
<span className="w-2 h-2 bg-green-500 rounded-full animate-pulse" />
Live
</span>
)}
</div>
<button
onClick={onClose}
className="text-gray-400 hover:text-gray-600 transition-colors p-1"
>
</button>
</div>
{/* Filter */}
<div className="flex gap-1 p-3 border-b border-gray-100 overflow-x-auto">
{filterOptions.map(opt => (
<button
key={opt.value}
onClick={() => setFilter(opt.value)}
className={`px-3 py-1 rounded-full text-xs font-medium whitespace-nowrap transition-colors ${
filter === opt.value
? 'bg-blue-500 text-white'
: 'bg-gray-100 text-gray-600 hover:bg-gray-200'
}`}
>
{opt.label}
</button>
))}
</div>
{/* Content */}
<div className="flex-1 overflow-y-auto p-4">
{filteredSuggestions.length === 0 ? (
<div className="flex flex-col items-center justify-center h-full text-gray-400">
<div className="text-4xl mb-3">🤖</div>
<p className="text-sm">Keine Vorschläge vorhanden</p>
<p className="text-xs mt-1">Die KI analysiert deinen Kontext...</p>
</div>
) : (
<div>
{filteredSuggestions.map(suggestion => (
<SuggestionCard
n key={suggestion.id}
suggestion={suggestion}
onDismiss={dismiss}
onAct={act}
/>
))}
</div>
)}
</div>
{/* Footer */}
<div className="p-3 border-t border-gray-200 text-center">
<span className="text-xs text-gray-400">
{suggestions.length} Vorschläge insgesamt
</span>
</div>
</aside>
</>
);
}