diff --git a/src/server/ai/tools/get-current-time.ts b/src/server/ai/tools/get-current-time.ts index 4077a8f..34a20e8 100644 --- a/src/server/ai/tools/get-current-time.ts +++ b/src/server/ai/tools/get-current-time.ts @@ -10,6 +10,7 @@ export function createGetCurrentTime(logger?: Logger) { inputSchema: z.object({ timezone: z.string().optional().describe("IANA 时区名称,如 'Asia/Shanghai'、'America/New_York'"), }), + metadata: { displayName: "获取当前时间" }, }); } diff --git a/src/web/consoles/workbench/components/chat/ChatPanel.tsx b/src/web/consoles/workbench/components/chat/ChatPanel.tsx index 9f47098..3b815fa 100644 --- a/src/web/consoles/workbench/components/chat/ChatPanel.tsx +++ b/src/web/consoles/workbench/components/chat/ChatPanel.tsx @@ -1,5 +1,5 @@ import { useChat } from "@ai-sdk/react"; -import { CopyOutlined, EditOutlined, RedoOutlined, RobotOutlined } from "@ant-design/icons"; +import { ArrowDownOutlined, CopyOutlined, EditOutlined, RedoOutlined, RobotOutlined } from "@ant-design/icons"; import { useQueryClient } from "@tanstack/react-query"; import { DefaultChatTransport, type UIMessage } from "ai"; import { App, Button, Card, Flex, Input, Spin, Typography } from "antd"; @@ -17,6 +17,7 @@ import { ChatInputArea } from "./ChatInputArea"; import { ReasoningPart } from "./parts/ReasoningPart"; import { TextPart } from "./parts/TextPart"; import { ToolPart } from "./parts/ToolPart"; +import { useChatScroll } from "./use-chat-scroll"; interface ChatPanelProps { conversationId: null | string; @@ -55,6 +56,8 @@ export function ChatPanel({ conversationId, onConversationCreated, projectId }: const isLoading = status === "submitted" || status === "streaming"; + const { isAtBottom, scrollToBottom } = useChatScroll({ messages, scrollRef, status }); + useEffect(() => { if (!conversationId) { setMessages([]); @@ -125,10 +128,6 @@ export function ChatPanel({ conversationId, onConversationCreated, projectId }: }); }, [conversationId, textModels, projectId, logger]); - useEffect(() => { - scrollRef.current?.scrollTo({ behavior: "smooth", top: scrollRef.current.scrollHeight }); - }, [messages]); - useEffect(() => { if (status === "ready" && conversationId) { void queryClient.invalidateQueries({ queryKey: ["conversations", projectId] }); @@ -380,6 +379,15 @@ export function ChatPanel({ conversationId, onConversationCreated, projectId }: )} + {!isAtBottom && ( +