* add platform guards * add service management * fix types * move to zustand for servicehub * update App Updater * update tauri missing move * update app updater * refactor: move PlatformFeatures to separate const file 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * change tauri fetch name * update implementation * update extension fetch * make web version run properly * disabled unused web settings * fix all tests * fix lint * fix tests * add mock for extension * fix build * update make and mise * fix tsconfig for web-extensions * fix loader type * cleanup * fix test * update error handling + mcp should be working * Update mcp init * use separate is_web_app build property * Remove fixed model catalog url * fix additional tests * fix download issue (event emitter not implemented correctly) * Update Title html * fix app logs * update root tsx render timing --------- Co-authored-by: Claude <noreply@anthropic.com>
31 lines
957 B
TypeScript
31 lines
957 B
TypeScript
import { useEffect } from 'react'
|
|
import { getServiceHub } from '@/hooks/useServiceHub'
|
|
import { MCPTool } from '@/types/completion'
|
|
import { SystemEvent } from '@/types/events'
|
|
import { useAppState } from './useAppState'
|
|
|
|
export const useTools = () => {
|
|
const { updateTools } = useAppState()
|
|
|
|
useEffect(() => {
|
|
function setTools() {
|
|
getServiceHub().mcp().getTools().then((data: MCPTool[]) => {
|
|
updateTools(data)
|
|
}).catch((error) => {
|
|
console.error('Failed to fetch MCP tools:', error)
|
|
})
|
|
}
|
|
setTools()
|
|
|
|
let unsubscribe = () => {}
|
|
getServiceHub().events().listen(SystemEvent.MCP_UPDATE, setTools).then((unsub) => {
|
|
// Unsubscribe from the event when the component unmounts
|
|
unsubscribe = unsub
|
|
}).catch((error) => {
|
|
console.error('Failed to set up MCP update listener:', error)
|
|
})
|
|
return unsubscribe
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, [])
|
|
}
|