mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-26 03:31:24 +08:00
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:
parent
c808b8d2dc
commit
0e5f43da10
@ -1,5 +1,7 @@
|
||||
import { CheckCircleOutlined, QuestionCircleOutlined, WarningOutlined } from '@ant-design/icons'
|
||||
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 { FC, useEffect, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
@ -13,8 +15,10 @@ interface Props {
|
||||
}
|
||||
|
||||
const InstallNpxUv: FC<Props> = ({ mini = false }) => {
|
||||
const [isUvInstalled, setIsUvInstalled] = useState(true)
|
||||
const [isBunInstalled, setIsBunInstalled] = useState(true)
|
||||
const dispatch = useAppDispatch()
|
||||
const isUvInstalled = useAppSelector((state) => state.mcp.isUvInstalled)
|
||||
const isBunInstalled = useAppSelector((state) => state.mcp.isBunInstalled)
|
||||
|
||||
const [isInstallingUv, setIsInstallingUv] = useState(false)
|
||||
const [isInstallingBun, setIsInstallingBun] = useState(false)
|
||||
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 { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const checkBinaries = async () => {
|
||||
const uvExists = await window.api.isBinaryExist('uv')
|
||||
const bunExists = await window.api.isBinaryExist('bun')
|
||||
const { uvPath, bunPath, dir } = await window.api.mcp.getInstallInfo()
|
||||
|
||||
setIsUvInstalled(uvExists)
|
||||
setIsBunInstalled(bunExists)
|
||||
dispatch(setIsUvInstalled(uvExists))
|
||||
dispatch(setIsBunInstalled(bunExists))
|
||||
setUvPath(uvPath)
|
||||
setBunPath(bunPath)
|
||||
setBinariesDir(dir)
|
||||
|
||||
@ -3,7 +3,9 @@ import Logger from '@renderer/config/logger'
|
||||
import type { MCPConfig, MCPServer } from '@renderer/types'
|
||||
|
||||
export const initialState: MCPConfig = {
|
||||
servers: []
|
||||
servers: [],
|
||||
isUvInstalled: true,
|
||||
isBunInstalled: true
|
||||
}
|
||||
|
||||
const mcpSlice = createSlice({
|
||||
@ -30,6 +32,12 @@ const mcpSlice = createSlice({
|
||||
if (index !== -1) {
|
||||
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: {
|
||||
@ -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 const { getActiveServers, getAllServers } = mcpSlice.selectors
|
||||
|
||||
@ -600,6 +600,8 @@ export interface GetMCPPromptResponse {
|
||||
|
||||
export interface MCPConfig {
|
||||
servers: MCPServer[]
|
||||
isUvInstalled: boolean
|
||||
isBunInstalled: boolean
|
||||
}
|
||||
|
||||
interface BaseToolResponse {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user