From 3f5b737fbb5829afae87efc2990db0ba77ef8e52 Mon Sep 17 00:00:00 2001 From: sp mac bookpro 2605 Date: Sat, 6 Jun 2026 13:45:07 +0800 Subject: [PATCH] chat: add history/new session actions and fix icons --- src/components/icons.tsx | 43 +++++++++++++++++++++++++ src/pages/chat/ChatPage.tsx | 15 +++++++++ src/pages/chat/components/ChatInput.tsx | 22 +++++++++++-- src/styles.css | 21 ++++++++++++ 4 files changed, 98 insertions(+), 3 deletions(-) diff --git a/src/components/icons.tsx b/src/components/icons.tsx index d25400b..215ee49 100644 --- a/src/components/icons.tsx +++ b/src/components/icons.tsx @@ -31,3 +31,46 @@ export function ProductCopyIcon(props: SVGProps) { ); } +export function HistoryIcon(props: SVGProps) { + const { width = 20, height = 20, ...rest } = props; + return ( + + + + ); +} + +export function NewChatIcon(props: SVGProps) { + const { width = 20, height = 20, ...rest } = props; + return ( + + + + + + ); +} diff --git a/src/pages/chat/ChatPage.tsx b/src/pages/chat/ChatPage.tsx index bb02799..5f639b6 100644 --- a/src/pages/chat/ChatPage.tsx +++ b/src/pages/chat/ChatPage.tsx @@ -2,6 +2,7 @@ import { useEffect, useRef, useState } from 'react'; import { App as AntApp, Empty } from 'antd'; import { useNavigate, useParams, useSearchParams } from 'react-router-dom'; import type { ModelOverrides } from '../../api'; +import { SessionAPI } from '../../api'; import AgentSidebar from './components/AgentSidebar'; import ChatHeader from './components/ChatHeader'; import ChatBody from './components/ChatBody'; @@ -146,6 +147,20 @@ export default function ChatPage() { const selected = sender.modelOptions.find((m) => m.value === modelId); setOverrides((o) => ({ ...o, model_id: String(modelId), model: selected?.label || String(modelId) })); }} + onOpenHistory={() => setHistoryDrawerOpen(true)} + onNewSession={async () => { + if (!id) return; + abortRef.current?.abort(); + try { + const created = await SessionAPI.create(id); + setHighlightId(null); + setMessages(() => []); + setBranches({}); + setSessionId(created.id); + } catch (e: any) { + message.error('创建会话失败:' + (e?.message ?? e)); + } + }} /> )} diff --git a/src/pages/chat/components/ChatInput.tsx b/src/pages/chat/components/ChatInput.tsx index 59408d7..c2c2383 100644 --- a/src/pages/chat/components/ChatInput.tsx +++ b/src/pages/chat/components/ChatInput.tsx @@ -1,6 +1,7 @@ import { ArrowUpOutlined, BookOutlined, CloseOutlined, DownOutlined, PaperClipOutlined } from '@ant-design/icons'; -import { Button, Image as AntImage, Input, Select, Tag, Upload } from 'antd'; +import { Button, Image as AntImage, Input, Select, Tag, Tooltip, Upload } from 'antd'; import type { ChatAttachment } from '../../../api'; +import { HistoryIcon, NewChatIcon } from '../../../components/icons'; export default function ChatInput(props: { input: string; @@ -17,6 +18,8 @@ export default function ChatInput(props: { modelOptions: Array<{ value: string; label: string }>; activeModelValue: string; onChangeModel: (modelId: string) => void; + onOpenHistory: () => void; + onNewSession: () => void; }) { const { input, @@ -32,7 +35,9 @@ export default function ChatInput(props: { onOpenTpl, modelOptions, activeModelValue, - onChangeModel + onChangeModel, + onOpenHistory, + onNewSession } = props; return ( @@ -59,6 +64,18 @@ export default function ChatInput(props: {
+
+ + + + + + +
); } - diff --git a/src/styles.css b/src/styles.css index d588cdd..cea0cde 100644 --- a/src/styles.css +++ b/src/styles.css @@ -749,6 +749,27 @@ body { padding: 14px 16px 12px; min-height: 110px; box-shadow: var(--shadow-sm); + position: relative; +} + +.chat-input-actions { + position: absolute; + top: 10px; + right: 12px; + display: flex; + gap: 4px; + z-index: 2; +} + +.chat-input-action-btn { + display: inline-flex; + align-items: center; + gap: 6px; + color: var(--color-text-secondary); +} + +.chat-input-action-btn:hover { + color: var(--color-text); } .chat-input-stack {