feat(web): integrate Claude LLM streaming with markdown rendering

- Add Anthropic SDK with DeepSeek-compatible API config
- Streaming tool-use loop in WebSocket chat handler
- GitHub-style markdown rendering with markdown-it
- Tool status indicators and thinking states in chat UI
- Fix Tailwind content path and CSS border utility

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 03:22:15 +08:00
parent d6b18fb7dc
commit 001dbde9f4
15 changed files with 759 additions and 95 deletions

View File

@@ -3,13 +3,14 @@ import { useAppStore } from '@/store';
import { useChat } from '@/hooks/useChat';
import { ChatMessage } from './ChatMessage';
import { ChatInput } from './ChatInput';
import { PipelineProgress } from './PipelineProgress';
import { ScrollArea } from '@/components/ui/scroll-area';
import { Button } from '@/components/ui/button';
import { RefreshCw } from 'lucide-react';
import { RefreshCw, Loader2 } from 'lucide-react';
export function ChatView() {
const { activeConversationId, conversations, setConversations, selectedAccountId } = useAppStore();
const { messages, connected, send, createConversation } = useChat(activeConversationId);
const { activeConversationId, setConversations, selectedAccountId } = useAppStore();
const { messages, connected, thinking, toolStatus, send, createConversation } = useChat(activeConversationId);
const [manifestPath, setManifestPath] = useState<string | null>(null);
useEffect(() => {
@@ -19,7 +20,6 @@ export function ChatView() {
.catch(() => {});
}, [messages]);
// Check for associated manifest in messages
useEffect(() => {
const toolMsgs = messages.filter((m) => m.role === 'tool');
if (toolMsgs.length > 0) {
@@ -80,12 +80,21 @@ export function ChatView() {
</Button>
)}
</div>
<ScrollArea className="flex-1 px-4 py-4">
{messages.map((msg) => (
<ChatMessage key={msg.id} message={msg} />
))}
{thinking && (
<div className="flex items-center gap-2 text-zinc-500 text-sm py-2">
<Loader2 size={14} className="animate-spin" />
{toolStatus || '思考中...'}
</div>
)}
</ScrollArea>
<ChatInput onSend={send} />
<ChatInput onSend={send} disabled={thinking} />
</div>
);
}