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 (
-
-
+
+