From d7bf0e5c9dd0e76511e138c8a17901b44b6e2544 Mon Sep 17 00:00:00 2001 From: sp mac bookpro 2605 Date: Sat, 6 Jun 2026 14:11:49 +0800 Subject: [PATCH] chat: reposition session actions and refine history drawer --- src/components/SessionSidebar.tsx | 11 +- src/components/icons.tsx | 2 +- src/pages/chat/components/ChatDrawers.tsx | 18 ++- src/pages/chat/components/ChatInput.tsx | 138 +++++++++++----------- src/styles.css | 16 ++- 5 files changed, 108 insertions(+), 77 deletions(-) diff --git a/src/components/SessionSidebar.tsx b/src/components/SessionSidebar.tsx index 5dc321d..f243473 100644 --- a/src/components/SessionSidebar.tsx +++ b/src/components/SessionSidebar.tsx @@ -9,9 +9,10 @@ interface Props { onChange: (sessionId: string, options?: { highlightMessageId?: string }) => void; refreshTick?: number; theme?: 'light' | 'dark'; + showNewButton?: boolean; } -export default function SessionSidebar({ agentId, activeSessionId, onChange, refreshTick, theme = 'light' }: Props) { +export default function SessionSidebar({ agentId, activeSessionId, onChange, refreshTick, theme = 'light', showNewButton = true }: Props) { const { message } = AntApp.useApp(); const [tab, setTab] = useState<'active' | 'archived'>('active'); const [active, setActive] = useState([]); @@ -269,9 +270,11 @@ export default function SessionSidebar({ agentId, activeSessionId, onChange, ref return (
- + {showNewButton && ( + + )} ) { diff --git a/src/pages/chat/components/ChatDrawers.tsx b/src/pages/chat/components/ChatDrawers.tsx index f40a17a..1d5c2bc 100644 --- a/src/pages/chat/components/ChatDrawers.tsx +++ b/src/pages/chat/components/ChatDrawers.tsx @@ -1,4 +1,4 @@ -import { Button, Drawer, Empty, InputNumber, Slider } from 'antd'; +import { Button, Drawer, Dropdown, Empty, InputNumber, Slider } from 'antd'; import type { Agent, ModelOverrides } from '../../../api'; import McpResourcesDrawer from '../../../components/McpResourcesDrawer'; import SessionSidebar from '../../../components/SessionSidebar'; @@ -142,12 +142,25 @@ export default function ChatDrawers(props: { setHistoryDrawerOpen(false)} open={historyDrawerOpen} styles={{ body: { padding: 0 } }} + extra={ + + + + } > {agentId ? ( ) : ( diff --git a/src/pages/chat/components/ChatInput.tsx b/src/pages/chat/components/ChatInput.tsx index c2c2383..1e43c96 100644 --- a/src/pages/chat/components/ChatInput.tsx +++ b/src/pages/chat/components/ChatInput.tsx @@ -63,7 +63,7 @@ export default function ChatInput(props: { ))}
-
+
-
-
- setInput(e.target.value)} - placeholder="问我任何问题..." - autoSize={{ minRows: 3, maxRows: 10 }} - onKeyDown={(e) => { - if (e.key !== 'Enter') return; - if ((e as any).isComposing) return; +
+
+ setInput(e.target.value)} + placeholder="问我任何问题..." + autoSize={{ minRows: 3, maxRows: 10 }} + onKeyDown={(e) => { + if (e.key !== 'Enter') return; + if ((e as any).isComposing) return; - if (e.metaKey || e.ctrlKey) { - e.preventDefault(); - const el = e.currentTarget; - const start = el.selectionStart ?? input.length; - const end = el.selectionEnd ?? input.length; - const next = input.slice(0, start) + '\n' + input.slice(end); - setInput(next); - requestAnimationFrame(() => { - el.selectionStart = el.selectionEnd = start + 1; - }); - return; - } + if (e.metaKey || e.ctrlKey) { + e.preventDefault(); + const el = e.currentTarget; + const start = el.selectionStart ?? input.length; + const end = el.selectionEnd ?? input.length; + const next = input.slice(0, start) + '\n' + input.slice(end); + setInput(next); + requestAnimationFrame(() => { + el.selectionStart = el.selectionEnd = start + 1; + }); + return; + } - if (!e.shiftKey && !e.altKey) { - e.preventDefault(); - onSend(); - } - }} - className="chat-input-textarea" - disabled={sending} - /> + if (!e.shiftKey && !e.altKey) { + e.preventDefault(); + onSend(); + } + }} + className="chat-input-textarea" + disabled={sending} + /> -
-
- } + placeholder="选择模型" + onChange={onChangeModel} + /> - { - onAttach(files as File[]); - return false; - }} - showUploadList={false} - accept=".txt,.md,.markdown,.json,.csv,.pdf,.docx,.html,.htm,image/png,image/jpeg,image/webp,image/gif" - > -
+ + {sending ? ( +
- - {sending ? ( -
diff --git a/src/styles.css b/src/styles.css index cea0cde..60e862c 100644 --- a/src/styles.css +++ b/src/styles.css @@ -749,13 +749,16 @@ body { padding: 14px 16px 12px; min-height: 110px; box-shadow: var(--shadow-sm); +} + +.chat-input-card-wrap { position: relative; } .chat-input-actions { position: absolute; - top: 10px; - right: 12px; + top: -10px; + right: 8px; display: flex; gap: 4px; z-index: 2; @@ -772,6 +775,15 @@ body { color: var(--color-text); } +.chat-input-action-btn-primary { + color: var(--color-brand); +} + +.chat-input-action-btn-primary:hover { + color: var(--color-brand); + opacity: 0.9; +} + .chat-input-stack { display: flex; flex-direction: column;