fix: mcp uv&bun installation status icon in nav bar not updated after… (#6654)

fix: mcp uv&bun installation status icon in nav bar not updated after installed

Signed-off-by: aprilandjan <merlin.ye@qq.com>
This commit is contained in:
May 2025-06-02 23:29:23 +08:00 committed by GitHub
parent ecbd283779
commit 7724b49ec4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 7 deletions

View File

@ -1,5 +1,7 @@
import { CheckCircleOutlined, QuestionCircleOutlined, WarningOutlined } from '@ant-design/icons' import { CheckCircleOutlined, QuestionCircleOutlined, WarningOutlined } from '@ant-design/icons'
import { Center, VStack } from '@renderer/components/Layout' import { Center, VStack } from '@renderer/components/Layout'
import { useAppDispatch, useAppSelector } from '@renderer/store'
import { setIsBunInstalled, setIsUvInstalled } from '@renderer/store/mcp'
import { Alert, Button } from 'antd' import { Alert, Button } from 'antd'
import { FC, useEffect, useState } from 'react' import { FC, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
@ -13,8 +15,10 @@ interface Props {
} }
const InstallNpxUv: FC<Props> = ({ mini = false }) => { const InstallNpxUv: FC<Props> = ({ mini = false }) => {
const [isUvInstalled, setIsUvInstalled] = useState(true) const dispatch = useAppDispatch()
const [isBunInstalled, setIsBunInstalled] = useState(true) const isUvInstalled = useAppSelector((state) => state.mcp.isUvInstalled)
const isBunInstalled = useAppSelector((state) => state.mcp.isBunInstalled)
const [isInstallingUv, setIsInstallingUv] = useState(false) const [isInstallingUv, setIsInstallingUv] = useState(false)
const [isInstallingBun, setIsInstallingBun] = useState(false) const [isInstallingBun, setIsInstallingBun] = useState(false)
const [uvPath, setUvPath] = useState<string | null>(null) const [uvPath, setUvPath] = useState<string | null>(null)
@ -22,14 +26,13 @@ const InstallNpxUv: FC<Props> = ({ mini = false }) => {
const [binariesDir, setBinariesDir] = useState<string | null>(null) const [binariesDir, setBinariesDir] = useState<string | null>(null)
const { t } = useTranslation() const { t } = useTranslation()
const navigate = useNavigate() const navigate = useNavigate()
const checkBinaries = async () => { const checkBinaries = async () => {
const uvExists = await window.api.isBinaryExist('uv') const uvExists = await window.api.isBinaryExist('uv')
const bunExists = await window.api.isBinaryExist('bun') const bunExists = await window.api.isBinaryExist('bun')
const { uvPath, bunPath, dir } = await window.api.mcp.getInstallInfo() const { uvPath, bunPath, dir } = await window.api.mcp.getInstallInfo()
setIsUvInstalled(uvExists) dispatch(setIsUvInstalled(uvExists))
setIsBunInstalled(bunExists) dispatch(setIsBunInstalled(bunExists))
setUvPath(uvPath) setUvPath(uvPath)
setBunPath(bunPath) setBunPath(bunPath)
setBinariesDir(dir) setBinariesDir(dir)

View File

@ -3,7 +3,9 @@ import Logger from '@renderer/config/logger'
import type { MCPConfig, MCPServer } from '@renderer/types' import type { MCPConfig, MCPServer } from '@renderer/types'
export const initialState: MCPConfig = { export const initialState: MCPConfig = {
servers: [] servers: [],
isUvInstalled: true,
isBunInstalled: true
} }
const mcpSlice = createSlice({ const mcpSlice = createSlice({
@ -30,6 +32,12 @@ const mcpSlice = createSlice({
if (index !== -1) { if (index !== -1) {
state.servers[index].isActive = action.payload.isActive state.servers[index].isActive = action.payload.isActive
} }
},
setIsUvInstalled: (state, action: PayloadAction<boolean>) => {
state.isUvInstalled = action.payload
},
setIsBunInstalled: (state, action: PayloadAction<boolean>) => {
state.isBunInstalled = action.payload
} }
}, },
selectors: { selectors: {
@ -40,7 +48,15 @@ const mcpSlice = createSlice({
} }
}) })
export const { setMCPServers, addMCPServer, updateMCPServer, deleteMCPServer, setMCPServerActive } = mcpSlice.actions export const {
setMCPServers,
addMCPServer,
updateMCPServer,
deleteMCPServer,
setMCPServerActive,
setIsBunInstalled,
setIsUvInstalled
} = mcpSlice.actions
// Export the generated selectors from the slice // Export the generated selectors from the slice
export const { getActiveServers, getAllServers } = mcpSlice.selectors export const { getActiveServers, getAllServers } = mcpSlice.selectors

View File

@ -600,6 +600,8 @@ export interface GetMCPPromptResponse {
export interface MCPConfig { export interface MCPConfig {
servers: MCPServer[] servers: MCPServer[]
isUvInstalled: boolean
isBunInstalled: boolean
} }
interface BaseToolResponse { interface BaseToolResponse {