/** * AIUIControlIndicator — Visual indication when AI is controlling the UI. * * Task 4.11: Visuelle KI-Indikation * When AI executes an action: highlight effect + toast "KI führt Aktion aus...". * User sees that AI is acting. */ import React, { useEffect } from 'react'; import { Bot, X } from 'lucide-react'; import { useAIUIControlStore } from '@/store/aiUIControlStore'; import { useUIStore } from '@/store/uiStore'; import { useTranslation } from 'react-i18next'; export function AIUIControlIndicator() { const { t } = useTranslation(); const aiActive = useAIUIControlStore((s) => s.aiActive); const activeCommand = useAIUIControlStore((s) => s.activeCommand); const clearPending = useAIUIControlStore((s) => s.clearPending); const addToast = useUIStore((s) => s.addToast); // Show toast when a new command starts useEffect(() => { if (aiActive && activeCommand) { const desc = activeCommand.description || t(`ai.uiControl.${actionToKey(activeCommand.action)}`, getCommandFallback(activeCommand.action)); addToast({ type: 'info', message: `${t('ai.uiControl.executing', 'KI führt Aktion aus')}: ${desc}`, duration: 4000, }); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [aiActive, activeCommand?.command_id]); if (!aiActive) return null; return (
); } function actionToKey(action: string): string { const keyMap: Record = { navigate: 'navigate', filter: 'filter', open_contact: 'openContact', modal: 'modal', tab: 'tab', settings: 'settings', }; return keyMap[action] || action; } function getCommandFallback(action: string): string { const fallbacks: Record = { navigate: 'Navigation', filter: 'Filter setzen', open_contact: 'Kontakt öffnen', modal: 'Dialog öffnen', tab: 'Tab wechseln', settings: 'Einstellungen ändern', }; return fallbacks[action] || action; }