From 6e3f4b8d043c83cad9d3cb1412c468b87974d3bc Mon Sep 17 00:00:00 2001 From: gqt <3217233537@qq.com> Date: Mon, 13 Jul 2026 12:00:01 +0800 Subject: [PATCH] feat: add streaming chat and evidence workspace --- web/src/app/AppLayout.tsx | 2 + web/src/app/router.tsx | 6 +- web/src/features/chat/ChatComposer.tsx | 22 +++++++ web/src/features/chat/ChatPage.tsx | 61 +++++++++++++++++++ web/src/features/chat/EvidencePanel.tsx | 16 +++++ web/src/features/chat/MessageList.tsx | 28 +++++++++ web/src/features/chat/SessionList.tsx | 52 ++++++++++++++++ web/src/features/chat/api.ts | 25 ++++++++ web/src/features/chat/store.ts | 41 +++++++++++++ web/src/features/chat/useChatStream.ts | 39 ++++++++++++ web/src/index.css | 81 +++++++++++++++++++++++++ 11 files changed, 370 insertions(+), 3 deletions(-) create mode 100644 web/src/features/chat/ChatComposer.tsx create mode 100644 web/src/features/chat/ChatPage.tsx create mode 100644 web/src/features/chat/EvidencePanel.tsx create mode 100644 web/src/features/chat/MessageList.tsx create mode 100644 web/src/features/chat/SessionList.tsx create mode 100644 web/src/features/chat/api.ts create mode 100644 web/src/features/chat/store.ts create mode 100644 web/src/features/chat/useChatStream.ts diff --git a/web/src/app/AppLayout.tsx b/web/src/app/AppLayout.tsx index 76f8aad..e018204 100644 --- a/web/src/app/AppLayout.tsx +++ b/web/src/app/AppLayout.tsx @@ -4,6 +4,7 @@ import { useState } from 'react' import { NavLink, Outlet } from 'react-router-dom' import { Button } from '../components/ui/button' +import { SessionList } from '../features/chat/SessionList' import { cn } from '../lib/utils' function Navigation({ onNavigate }: { onNavigate?: () => void }) { @@ -22,6 +23,7 @@ function Navigation({ onNavigate }: { onNavigate?: () => void }) { 文档资料库 +
严格知识库模式回答必须引用已索引资料
diff --git a/web/src/app/router.tsx b/web/src/app/router.tsx index 6e71c75..44ac9fd 100644 --- a/web/src/app/router.tsx +++ b/web/src/app/router.tsx @@ -1,7 +1,7 @@ import { Navigate, createBrowserRouter } from 'react-router-dom' import { AppLayout } from './AppLayout' -import { PlaceholderPage } from './PlaceholderPage' +import { ChatPage } from '../features/chat/ChatPage' import { DocumentsPage } from '../features/documents/DocumentsPage' export const router = createBrowserRouter([ @@ -10,8 +10,8 @@ export const router = createBrowserRouter([ element: , children: [ { index: true, element: }, - { path: 'chat', element: }, - { path: 'chat/:sessionId', element: }, + { path: 'chat', element: }, + { path: 'chat/:sessionId', element: }, { path: 'documents', element: }, { path: 'documents/:documentId', element: }, ], diff --git a/web/src/features/chat/ChatComposer.tsx b/web/src/features/chat/ChatComposer.tsx new file mode 100644 index 0000000..ba9334c --- /dev/null +++ b/web/src/features/chat/ChatComposer.tsx @@ -0,0 +1,22 @@ +import { SendHorizontal, Square } from 'lucide-react' +import { useState } from 'react' + +import { Button } from '../../components/ui/button' + +type Props = { streaming: boolean; onSend: (query: string) => void; onCancel: () => void } + +export function ChatComposer({ streaming, onSend, onCancel }: Props) { + const [query, setQuery] = useState('') + function submit() { + const value = query.trim() + if (!value || streaming) return + setQuery(''); onSend(value) + } + return ( +
+