diff --git a/src/pages/options/routes/Agent/Chat/index.tsx b/src/pages/options/routes/Agent/Chat/index.tsx index 2c6cccb70..810f4c99d 100644 --- a/src/pages/options/routes/Agent/Chat/index.tsx +++ b/src/pages/options/routes/Agent/Chat/index.tsx @@ -1,7 +1,16 @@ import { useCallback, useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { notify } from "@App/pages/components/ui/toast"; -import { ChevronLeft, Download, PanelLeftClose, PanelLeftOpen, Sparkles, SquarePen } from "lucide-react"; +import { + AlertCircle, + ChevronLeft, + Download, + PanelLeftClose, + PanelLeftOpen, + Settings, + Sparkles, + SquarePen +} from "lucide-react"; import type { AgentModelConfig } from "@App/app/service/agent/core/types"; import { agentChatRepo } from "@App/app/repo/agent_chat"; import { agentClient } from "@App/pages/store/features/script"; @@ -67,7 +76,6 @@ export default function AgentChat() { const [defaultModelId, setDefaultModelId] = useState(""); const [modelsLoaded, setModelsLoaded] = useState(false); const [collapsed, setCollapsed] = useState(false); - // 移动端在「列表」与「对话」两屏之间切换(窄屏放不下桌面三栏并排) const [mobileView, setMobileView] = useState<"list" | "chat">("list"); useEffect(() => { @@ -96,8 +104,6 @@ export default function AgentChat() { const [backgroundEnabled, setBackgroundEnabled] = useState(false); const { runningIds } = useRunningConversations(); - // 切换会话时,自动恢复该会话上次使用的模型。 - // 通过渲染期比较上一次的 activeId / conversations 同步状态(取代 effect 中的 setState,避免级联渲染)。 const [prevActiveId, setPrevActiveId] = useState(activeId); const [prevConversations, setPrevConversations] = useState(conversations); if (activeId !== prevActiveId || conversations !== prevConversations) { @@ -118,7 +124,6 @@ export default function AgentChat() { const activeModelName = models.find((m) => m.id === effectiveModelId)?.name || ""; const hasActiveConv = !!activeConv; - // 选中会话:移动端同时切到「对话」屏 const openConversation = useCallback( (id: string) => { setActiveId(id); @@ -137,7 +142,6 @@ export default function AgentChat() { void loadConversations(); }, [loadConversations]); - // 导出会话为 Markdown const handleExport = useCallback( async (id: string) => { const conv = conversations.find((c) => c.id === id); @@ -154,7 +158,6 @@ export default function AgentChat() { [conversations, t] ); - // 桌面端面板头带折叠按钮;移动端列表屏无折叠(全局抽屉导航)。 const renderConversationList = (collapsible: boolean) => ( ); - const chatArea = ( + const noModelsConfigured = modelsLoaded && models.length === 0; + + const chatArea = noModelsConfigured ? ( +
+
+
+ +
+
+

+ 未配置模型,请先在模型服务中添加 +

+

+ 在使用 AI 助手前,需要先配置至少一个 AI 模型服务。 +

+
+ + + 前往模型服务设置 + +
+
+ ) : ( ); - // 移动端:列表 / 对话 两屏切换。 - // 全局 MobileHeader(汉堡+抽屉) 已由 App 外壳常驻;本页对话屏只补一条「返回+标题+模型胶囊+操作」的上下文栏, - // 列表屏不再叠加第二条标题栏(避免双头部),由 ConversationList 自带的面板头承担新建/搜索。 if (isMobile) { if (mobileView === "chat") { return ( @@ -222,7 +247,6 @@ export default function AgentChat() { return (
- {/* 会话列表(可折叠) */}
- {/* 聊天列 */}
- {/* 头部:折叠钮 + (标题/模型胶囊) + 操作组(导出/新建) */}
); -} +} \ No newline at end of file