@@ -372,6 +372,13 @@ private void ApplyActiveMcpBaseUrl(string mcpBaseUrl, string? mcpApiKey = null,
372372 ? McpServerRestClientFactory . TryResolveApiKey ( _activeMcpBaseUrl )
373373 : mcpApiKey ? . Trim ( ) ;
374374
375+ _logger . LogInformation (
376+ "[Workspace Switch] ApplyActiveMcpBaseUrl: BaseUrl={BaseUrl}, ApiKey={ApiKeyPresent}, Bearer={BearerPresent}, WorkspacePath={WorkspacePath}" ,
377+ _activeMcpBaseUrl ,
378+ ! string . IsNullOrWhiteSpace ( _activeMcpApiKey ) ? $ "set({ _activeMcpApiKey ? [ ..Math . Min ( 8 , _activeMcpApiKey ? . Length ?? 0 ) ] } …)" : "null" ,
379+ ! string . IsNullOrWhiteSpace ( _activeBearerToken ) ? "set" : "null" ,
380+ workspaceRootPath ?? "(none)" ) ;
381+
375382 McpSessionService = new McpSessionLogService ( _activeMcpBaseUrl , _activeMcpApiKey , workspaceRootPath , _activeBearerToken ) ;
376383 _mcpTodoService = new McpTodoService ( _activeMcpBaseUrl , _activeMcpApiKey , workspaceRootPath , _activeBearerToken ) ;
377384 // Workspace endpoints always target the connection server, not the active workspace
@@ -1093,6 +1100,12 @@ private async Task SwitchWorkspaceConnectionAsync(WorkspaceConnectionOption opti
10931100 }
10941101
10951102 var selectedApiKey = await ResolveActiveConnectionApiKeyAsync ( option , selectedBaseUrl ) . ConfigureAwait ( true ) ;
1103+ _logger . LogInformation (
1104+ "[Workspace Switch] Resolved for '{DisplayName}': BaseUrl={BaseUrl}, ApiKey={ApiKey}, Bearer={Bearer}, WorkspacePath={WorkspacePath}" ,
1105+ option . DisplayName , selectedBaseUrl ,
1106+ ! string . IsNullOrWhiteSpace ( selectedApiKey ) ? $ "set({ selectedApiKey [ ..Math . Min ( 8 , selectedApiKey . Length ) ] } …)" : "null" ,
1107+ ! string . IsNullOrWhiteSpace ( _activeBearerToken ) ? "set" : "null" ,
1108+ option . WorkspaceRootPath ?? "(none)" ) ;
10961109 ApplyActiveMcpBaseUrl ( selectedBaseUrl , selectedApiKey , option . WorkspaceRootPath ) ;
10971110 await RefreshAllViewsForConnectionChangeAsync ( ) . ConfigureAwait ( true ) ;
10981111 _logger . LogInformation ( $ "[Workspace Switch] Successfully connected to '{ option . DisplayName } '") ;
@@ -1121,10 +1134,12 @@ private async Task RefreshAllViewsForConnectionChangeAsync()
11211134 try
11221135 {
11231136 await ReloadFromMcpAsyncInternal ( ) . ConfigureAwait ( true ) ;
1137+ _logger . LogDebug ( "[Workspace Switch] Session logs refreshed OK" ) ;
11241138 }
1125- catch ( Exception ex ) when ( ex is HttpRequestException or TaskCanceledException )
1139+ catch ( Exception ex )
11261140 {
1127- _logger . LogWarning ( ex , "[Workspace Switch] Session log refresh failed (endpoint may not exist on target workspace); continuing with remaining views" ) ;
1141+ _logger . LogWarning ( ex , "[Workspace Switch] Session log refresh failed ({ExType}: {ExMsg}); continuing" ,
1142+ ex . GetType ( ) . Name , ex . Message ) ;
11281143 }
11291144
11301145 if ( _todoViewModel != null )
@@ -1133,10 +1148,12 @@ private async Task RefreshAllViewsForConnectionChangeAsync()
11331148 try
11341149 {
11351150 await _todoViewModel . RefreshForConnectionChangeAsync ( ) . ConfigureAwait ( true ) ;
1151+ _logger . LogDebug ( "[Workspace Switch] Todo view refreshed OK" ) ;
11361152 }
1137- catch ( Exception ex ) when ( ex is HttpRequestException or TaskCanceledException )
1153+ catch ( Exception ex )
11381154 {
1139- _logger . LogWarning ( ex , "[Workspace Switch] Todo refresh failed; continuing" ) ;
1155+ _logger . LogWarning ( ex , "[Workspace Switch] Todo refresh failed ({ExType}: {ExMsg}); continuing" ,
1156+ ex . GetType ( ) . Name , ex . Message ) ;
11401157 }
11411158 }
11421159
@@ -1146,10 +1163,12 @@ private async Task RefreshAllViewsForConnectionChangeAsync()
11461163 try
11471164 {
11481165 await _workspaceViewModel . RefreshForConnectionChangeAsync ( ) . ConfigureAwait ( true ) ;
1166+ _logger . LogDebug ( "[Workspace Switch] Workspace view refreshed OK" ) ;
11491167 }
1150- catch ( Exception ex ) when ( ex is HttpRequestException or TaskCanceledException )
1168+ catch ( Exception ex )
11511169 {
1152- _logger . LogWarning ( ex , "[Workspace Switch] Workspace view refresh failed; continuing" ) ;
1170+ _logger . LogWarning ( ex , "[Workspace Switch] Workspace view refresh failed ({ExType}: {ExMsg}); continuing" ,
1171+ ex . GetType ( ) . Name , ex . Message ) ;
11531172 }
11541173 }
11551174
@@ -1159,10 +1178,12 @@ private async Task RefreshAllViewsForConnectionChangeAsync()
11591178 try
11601179 {
11611180 await _voiceConversationViewModel . RefreshForConnectionChangeAsync ( ) . ConfigureAwait ( true ) ;
1181+ _logger . LogDebug ( "[Workspace Switch] Voice view refreshed OK" ) ;
11621182 }
1163- catch ( Exception ex ) when ( ex is HttpRequestException or TaskCanceledException )
1183+ catch ( Exception ex )
11641184 {
1165- _logger . LogWarning ( ex , "[Workspace Switch] Voice refresh failed; continuing" ) ;
1185+ _logger . LogWarning ( ex , "[Workspace Switch] Voice refresh failed ({ExType}: {ExMsg}); continuing" ,
1186+ ex . GetType ( ) . Name , ex . Message ) ;
11661187 }
11671188 }
11681189
@@ -1171,8 +1192,12 @@ private async Task RefreshAllViewsForConnectionChangeAsync()
11711192
11721193 private async Task < McpWorkspaceHealthResult > ProbeWorkspaceConnectionHealthAsync ( string baseUrl )
11731194 {
1195+ _logger . LogInformation ( "[Workspace Switch] Probing health at {BaseUrl}..." , baseUrl ) ;
11741196 var service = new McpWorkspaceService ( baseUrl ) ;
1175- return await service . GetHealthAsync ( ) . ConfigureAwait ( true ) ;
1197+ var result = await service . GetHealthAsync ( ) . ConfigureAwait ( true ) ;
1198+ _logger . LogInformation ( "[Workspace Switch] Health probe for {BaseUrl}: Success={Success}, StatusCode={StatusCode}, Error={Error}" ,
1199+ baseUrl , result . Success , result . StatusCode , result . Error ?? "(none)" ) ;
1200+ return result ;
11761201 }
11771202
11781203 private static string FormatHealthFailure ( McpWorkspaceHealthResult health )
0 commit comments