From 3d9c981c2a38bf55da02ef414fa5ec6ef358793d Mon Sep 17 00:00:00 2001
From: ooodc <549496103@qq.com>
Date: Fri, 29 May 2026 23:12:53 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=89=8D=E7=AB=AF=E8=BE=93=E5=85=A5?=
=?UTF-8?q?=E6=A1=86=E4=BD=93=E9=AA=8C=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- AI 响应完成后自动聚焦输入框
- 输入框和发送按钮居中对齐
- 隐藏输入框滚动条
- 新建话题无需输入名称,自动生成默认标题
---
web/src/App.tsx | 9 +++------
web/src/components/Chat/ChatContainer.tsx | 1 +
web/src/components/Chat/MessageInput.tsx | 19 +++++++++++++++----
web/src/hooks/useChat.ts | 6 +++---
web/src/index.css | 10 ++++++++++
5 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/web/src/App.tsx b/web/src/App.tsx
index 4fa6794..3032825 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -142,12 +142,9 @@ function App() {
return
}
- const title = prompt('Enter topic title:')
- if (title) {
- const cmd = createTopic(title)
- handleCommand(cmd)
- sendMessage({ type: 'command', payload: JSON.stringify(cmd) })
- }
+ const cmd = createTopic()
+ handleCommand(cmd)
+ sendMessage({ type: 'command', payload: JSON.stringify(cmd) })
}, [sendMessage, handleCommand, createTopic, sessionId, isReadOnly])
const handleSwitchTopic = useCallback(
diff --git a/web/src/components/Chat/ChatContainer.tsx b/web/src/components/Chat/ChatContainer.tsx
index a1f29c6..45bc846 100644
--- a/web/src/components/Chat/ChatContainer.tsx
+++ b/web/src/components/Chat/ChatContainer.tsx
@@ -27,6 +27,7 @@ export function ChatContainer({
diff --git a/web/src/components/Chat/MessageInput.tsx b/web/src/components/Chat/MessageInput.tsx
index 8afc61d..68755be 100644
--- a/web/src/components/Chat/MessageInput.tsx
+++ b/web/src/components/Chat/MessageInput.tsx
@@ -4,6 +4,7 @@ import { useState, useRef, useEffect } from 'react'
interface MessageInputProps {
onSend: (content: string) => void
disabled?: boolean
+ isLoading?: boolean
placeholder?: string
isReadOnly?: boolean
channelName?: string
@@ -12,12 +13,14 @@ interface MessageInputProps {
export function MessageInput({
onSend,
disabled = false,
+ isLoading = false,
placeholder = '输入消息...按 / 查看命令',
isReadOnly = false,
channelName,
}: MessageInputProps) {
const [content, setContent] = useState('')
const textareaRef = useRef(null)
+ const wasLoadingRef = useRef(false)
useEffect(() => {
const textarea = textareaRef.current
@@ -27,6 +30,14 @@ export function MessageInput({
}
}, [content])
+ // 当 isLoading 从 true 变为 false 时,自动聚焦输入框
+ useEffect(() => {
+ if (wasLoadingRef.current && !isLoading && !isReadOnly) {
+ textareaRef.current?.focus()
+ }
+ wasLoadingRef.current = isLoading
+ }, [isLoading, isReadOnly])
+
const handleSend = () => {
if (content.trim() && !disabled && !isReadOnly) {
onSend(content.trim())
@@ -74,8 +85,8 @@ export function MessageInput({
return (
-
-
+
+