@@ -82,12 +82,9 @@ export const AIChatView = () => {
8282 const promptProvider = useInjectable < ChatAgentPromptProvider > ( ChatAgentPromptProvider ) ;
8383
8484 const layoutService = useInjectable < IMainLayoutService > ( IMainLayoutService ) ;
85- const mcpServerProxyService = useInjectable < MCPServerProxyService > ( TokenMCPServerProxyService ) ;
8685 const msgHistoryManager = aiChatService . sessionModel . history ;
8786 const containerRef = React . useRef < HTMLDivElement > ( null ) ;
8887 const chatInputRef = React . useRef < { setInputValue : ( v : string ) => void } | null > ( null ) ;
89- const dialogService = useInjectable < IDialogService > ( IDialogService ) ;
90- const aiNativeConfigService = useInjectable < AINativeConfigService > ( AINativeConfigService ) ;
9188
9289 const [ shortcutCommands , setShortcutCommands ] = React . useState < ChatSlashCommandItemModel [ ] > ( [ ] ) ;
9390
@@ -109,7 +106,6 @@ export const AIChatView = () => {
109106 const [ defaultAgentId , setDefaultAgentId ] = React . useState < string > ( '' ) ;
110107 const [ command , setCommand ] = React . useState ( '' ) ;
111108 const [ theme , setTheme ] = React . useState < string | null > ( null ) ;
112- const [ mcpToolsCount , setMcpToolsCount ] = React . useState < number > ( 0 ) ;
113109
114110 React . useEffect ( ( ) => {
115111 const featureSlashCommands = chatFeatureRegistry . getAllShortcutSlashCommand ( ) ;
@@ -661,25 +657,6 @@ export const AIChatView = () => {
661657 } ;
662658 } , [ aiChatService . sessionModel ] ) ;
663659
664- useEventEffect (
665- mcpServerProxyService . onChangeMCPServers ,
666- ( ) => {
667- mcpServerProxyService . getAllMCPTools ( ) . then ( ( tools ) => {
668- setMcpToolsCount ( tools . length ) ;
669- } ) ;
670- } ,
671- [ mcpServerProxyService ] ,
672- ) ;
673-
674- const handleShowMCPTools = React . useCallback ( async ( ) => {
675- const tools = await mcpServerProxyService . getAllMCPTools ( ) ;
676- dialogService . open ( {
677- message : < MCPToolsDialog tools = { tools } /> ,
678- type : MessageType . Empty ,
679- buttons : [ '关闭' ] ,
680- } ) ;
681- } , [ mcpServerProxyService , dialogService ] ) ;
682-
683660 return (
684661 < div id = { styles . ai_chat_view } >
685662 < div className = { styles . header_container } >
@@ -712,13 +689,6 @@ export const AIChatView = () => {
712689 </ Popover >
713690 ) ) }
714691 </ div >
715- < div className = { styles . header_operate_right } >
716- { aiNativeConfigService . capabilities . supportsMCP && (
717- < div className = { styles . tag } onClick = { handleShowMCPTools } >
718- { `MCP Tools: ${ mcpToolsCount } ` }
719- </ div >
720- ) }
721- </ div >
722692 </ div >
723693 < ChatInputWrapperRender
724694 onSend = { ( value , agentId , command ) =>
@@ -757,6 +727,9 @@ export function DefaultChatViewHeader({
757727 handleClear : ( ) => any ;
758728 handleCloseChatView : ( ) => any ;
759729} ) {
730+ const dialogService = useInjectable < IDialogService > ( IDialogService ) ;
731+ const aiNativeConfigService = useInjectable < AINativeConfigService > ( AINativeConfigService ) ;
732+ const mcpServerProxyService = useInjectable < MCPServerProxyService > ( TokenMCPServerProxyService ) ;
760733 const aiChatService = useInjectable < ChatInternalService > ( IChatInternalService ) ;
761734 const [ historyList , setHistoryList ] = React . useState < IChatHistoryItem [ ] > ( [ ] ) ;
762735 const [ currentTitle , setCurrentTitle ] = React . useState < string > ( '' ) ;
@@ -778,6 +751,15 @@ export function DefaultChatViewHeader({
778751 [ aiChatService ] ,
779752 ) ;
780753
754+ const handleShowMCPTools = React . useCallback ( async ( ) => {
755+ const tools = await mcpServerProxyService . getAllMCPTools ( ) ;
756+ dialogService . open ( {
757+ message : < MCPToolsDialog tools = { tools } /> ,
758+ type : MessageType . Empty ,
759+ buttons : [ '关闭' ] ,
760+ } ) ;
761+ } , [ mcpServerProxyService , dialogService ] ) ;
762+
781763 React . useEffect ( ( ) => {
782764 const getHistoryList = ( ) => {
783765 const currentMessages = aiChatService . sessionModel . history . getMessages ( ) ;
@@ -857,6 +839,23 @@ export function DefaultChatViewHeader({
857839 ariaLabel = { localize ( 'aiNative.operate.clear.title' ) }
858840 />
859841 </ Popover >
842+ { aiNativeConfigService . capabilities . supportsMCP && (
843+ < Popover
844+ overlayClassName = { styles . popover_icon }
845+ id = { 'ai-chat-header-tools' }
846+ position = { PopoverPosition . left }
847+ title = { localize ( 'aiNative.operate.tools.title' ) }
848+ >
849+ < EnhanceIcon
850+ wrapperClassName = { styles . action_btn }
851+ className = { getIcon ( 'menubar-tool' ) }
852+ onClick = { handleShowMCPTools }
853+ tabIndex = { 0 }
854+ role = 'button'
855+ ariaLabel = { localize ( 'aiNative.operate.tools.title' ) }
856+ />
857+ </ Popover >
858+ ) }
860859 < Popover
861860 overlayClassName = { styles . popover_icon }
862861 id = { 'ai-chat-header-close' }
0 commit comments