fix(desktop): component cleanup + dead code removal + DeerFlow ai-elements
- ChatArea: DeerFlow ai-elements annotations for accessibility - Conversation: remove unused Context, simplify message rendering - Delete dead modules: audit-logger.ts, gateway-reconnect.ts - Replace console.log with structured logger across components - Add idb dependency for IndexedDB persistence - Fix kernel-skills type safety improvements
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import { useState, useEffect, useRef, useCallback, useMemo, type MutableRefObject, type RefObject, type CSSProperties } from 'react';
|
||||
import { motion, AnimatePresence } from 'framer-motion';
|
||||
import { List, type ListImperativeAPI } from 'react-window';
|
||||
import { useChatStore, Message } from '../store/chatStore';
|
||||
import { useChatStore, type Message } from '../store/chatStore';
|
||||
import { useConversationStore } from '../store/chat/conversationStore';
|
||||
import { useArtifactStore } from '../store/chat/artifactStore';
|
||||
import { useConnectionStore } from '../store/connectionStore';
|
||||
import { useAgentStore } from '../store/agentStore';
|
||||
import { useConfigStore } from '../store/configStore';
|
||||
import { listen, type UnlistenFn } from '@tauri-apps/api/event';
|
||||
import { Paperclip, SquarePen, ArrowUp, MessageSquare, Download, X, FileText, Image as ImageIcon } from 'lucide-react';
|
||||
import { Button, EmptyState, MessageListSkeleton, LoadingDots } from './ui';
|
||||
import { ResizableChatLayout } from './ai/ResizableChatLayout';
|
||||
@@ -45,11 +47,14 @@ const VIRTUALIZATION_THRESHOLD = 100;
|
||||
|
||||
export function ChatArea() {
|
||||
const {
|
||||
messages, currentAgent, isStreaming, isLoading, currentModel,
|
||||
sendMessage: sendToGateway, setCurrentModel, initStreamListener,
|
||||
messages, isStreaming, isLoading,
|
||||
sendMessage: sendToGateway, initStreamListener,
|
||||
newConversation, chatMode, setChatMode, suggestions,
|
||||
totalInputTokens, totalOutputTokens,
|
||||
} = useChatStore();
|
||||
const currentAgent = useConversationStore((s) => s.currentAgent);
|
||||
const currentModel = useConversationStore((s) => s.currentModel);
|
||||
const setCurrentModel = useConversationStore((s) => s.setCurrentModel);
|
||||
const {
|
||||
artifacts, selectedArtifactId, artifactPanelOpen,
|
||||
selectArtifact, setArtifactPanelOpen,
|
||||
@@ -152,6 +157,29 @@ export function ChatArea() {
|
||||
return unsub;
|
||||
}, []);
|
||||
|
||||
// Listen for hand-execution-complete Tauri events
|
||||
useEffect(() => {
|
||||
let unlisten: UnlistenFn | undefined;
|
||||
listen<{ approvalId: string; handId: string; success: boolean; error?: string | null }>(
|
||||
'hand-execution-complete',
|
||||
(event) => {
|
||||
const { handId, success, error } = event.payload;
|
||||
useChatStore.getState().addMessage({
|
||||
id: crypto.randomUUID(),
|
||||
role: 'hand',
|
||||
content: success
|
||||
? `Hand ${handId} 执行完成`
|
||||
: `Hand ${handId} 执行失败: ${error || '未知错误'}`,
|
||||
timestamp: new Date(),
|
||||
handName: handId,
|
||||
handStatus: success ? 'completed' : 'failed',
|
||||
handResult: event.payload,
|
||||
});
|
||||
},
|
||||
).then((fn) => { unlisten = fn; });
|
||||
return () => { unlisten?.(); };
|
||||
}, []);
|
||||
|
||||
// Auto-scroll to bottom on new messages
|
||||
useEffect(() => {
|
||||
if (scrollRef.current && !useVirtualization) {
|
||||
|
||||
Reference in New Issue
Block a user