feat: Optimize MCP configuration logic

This commit is contained in:
Kadxy
2025-01-15 16:52:54 +08:00
parent ce13cf61a7
commit 8aa9a500fd
14 changed files with 766 additions and 653 deletions

View File

@@ -46,6 +46,7 @@ import QualityIcon from "../icons/hd.svg";
import StyleIcon from "../icons/palette.svg";
import PluginIcon from "../icons/plugin.svg";
import ShortcutkeyIcon from "../icons/shortcutkey.svg";
import McpToolIcon from "../icons/tool.svg";
import HeadphoneIcon from "../icons/headphone.svg";
import {
BOT_HELLO,
@@ -121,6 +122,7 @@ import { isEmpty } from "lodash-es";
import { getModelProvider } from "../utils/model";
import { RealtimeChat } from "@/app/components/realtime-chat";
import clsx from "clsx";
import { getAvailableClientsCount } from "../mcp/actions";
const localStorage = safeLocalStorage();
@@ -130,6 +132,27 @@ const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
loading: () => <LoadingIcon />,
});
const MCPAction = () => {
const navigate = useNavigate();
const [count, setCount] = useState<number>(0);
useEffect(() => {
const loadCount = async () => {
const count = await getAvailableClientsCount();
setCount(count);
};
loadCount();
}, []);
return (
<ChatAction
onClick={() => navigate(Path.McpMarket)}
text={`MCP${count ? ` (${count})` : ""}`}
icon={<McpToolIcon />}
/>
);
};
export function SessionConfigModel(props: { onClose: () => void }) {
const chatStore = useChatStore();
const session = chatStore.currentSession();
@@ -799,6 +822,7 @@ export function ChatActions(props: {
icon={<ShortcutkeyIcon />}
/>
)}
{!isMobileScreen && <MCPAction />}
</>
<div className={styles["chat-input-actions-end"]}>
{config.realtimeConfig.enable && (