@@ -166,6 +166,7 @@ type SessionManagerOptions = {
166166 onAssistantMessage : ( message : SessionMessage , shouldConnect : boolean ) => void ;
167167 onSessionEntryUpdated ?: ( entry : SessionEntry ) => void ;
168168 onLlmStreamProgress ?: ( progress : LlmStreamProgress ) => void ;
169+ onMcpStatusChanged ?: ( ) => void ;
169170} ;
170171
171172export type LlmStreamProgress = {
@@ -184,6 +185,7 @@ export class SessionManager {
184185 private readonly onAssistantMessage : ( message : SessionMessage , shouldConnect : boolean ) => void ;
185186 private readonly onSessionEntryUpdated ?: ( entry : SessionEntry ) => void ;
186187 private readonly onLlmStreamProgress ?: ( progress : LlmStreamProgress ) => void ;
188+ private readonly onMcpStatusChanged ?: ( ) => void ;
187189 private activeSessionId : string | null = null ;
188190 private activePromptController : AbortController | null = null ;
189191 private readonly sessionControllers = new Map < string , AbortController > ( ) ;
@@ -198,6 +200,7 @@ export class SessionManager {
198200 this . onAssistantMessage = options . onAssistantMessage ;
199201 this . onSessionEntryUpdated = options . onSessionEntryUpdated ;
200202 this . onLlmStreamProgress = options . onLlmStreamProgress ;
203+ this . onMcpStatusChanged = options . onMcpStatusChanged ;
201204 this . toolExecutor = new ToolExecutor ( this . projectRoot , this . createOpenAIClient , this . mcpManager ) ;
202205 this . mcpManager . prepare ( this . getResolvedSettings ( ) . mcpServers ) ;
203206 }
@@ -206,6 +209,10 @@ export class SessionManager {
206209 this . mcpManager . setOnToolsListChanged ( ( ) => {
207210 this . mcpToolDefinitions = this . mcpManager . getMcpToolDefinitions ( ) ;
208211 } ) ;
212+ // 设置状态变更回调,通知 UI 更新
213+ this . mcpManager . setOnStatusChanged ( ( ) => {
214+ this . onMcpStatusChanged ?.( ) ;
215+ } ) ;
209216 await this . mcpManager . initialize ( servers ) ;
210217 this . mcpToolDefinitions = this . mcpManager . getMcpToolDefinitions ( ) ;
211218 }
0 commit comments