@@ -12,116 +12,66 @@ export class RevealStep extends AzureWizardExecuteStep<RevealResourceWizardConte
1212 public readonly priority : number = 100 ;
1313
1414 public shouldExecute ( wizardContext : RevealResourceWizardContext | RevealResourceGroupWizardContext ) : boolean {
15- const should = ! ! wizardContext . azureResourceId ;
16- ext . outputChannel . appendLog ( vscode . l10n . t ( 'RevealStep shouldExecute: {0}, azureResourceId: {1}' , should , wizardContext . azureResourceId || 'undefined' ) ) ;
17- return should ;
15+ return ! ! wizardContext . azureResourceId ;
1816 }
1917
2018 public async execute ( context : RevealResourceWizardContext | RevealResourceGroupWizardContext ) : Promise < void > {
21- ext . outputChannel . appendLog ( vscode . l10n . t ( 'RevealStep starting execute with azureResourceId: {0}' , context . azureResourceId || 'undefined' ) ) ;
2219 const azureResourceId = nonNullProp ( context , 'azureResourceId' ) ;
23- ext . outputChannel . appendLog ( vscode . l10n . t ( 'Getting Azure Resource Extension API...' ) ) ;
2420 const api = await getAzureResourceExtensionApi ( ) ;
25- ext . outputChannel . appendLog ( vscode . l10n . t ( 'API obtained, focusing Azure Resources view...' ) ) ;
2621
2722 // Show the Azure Resources view first to ensure the reveal is visible
2823 await vscode . commands . executeCommand ( 'azureResourceGroups.focus' ) ;
29- ext . outputChannel . appendLog ( vscode . l10n . t ( 'View focused' ) ) ;
30-
31- // Extract provider from resource ID to determine which extension to activate
32- const providerMatch = azureResourceId . match ( / \/ p r o v i d e r s \/ ( [ ^ / ] + ) / i) ;
33- const provider = providerMatch ? providerMatch [ 1 ] : null ;
34- ext . outputChannel . appendLog ( vscode . l10n . t ( 'Resource provider: {0}' , provider || 'none' ) ) ;
35-
36- // Activate the appropriate Azure extension based on provider
37- if ( provider ) {
38- const extensionMap : Record < string , string > = {
39- // eslint-disable-next-line @typescript-eslint/naming-convention
40- 'Microsoft.App' : 'ms-azuretools.vscode-azurecontainerapps' ,
41- // eslint-disable-next-line @typescript-eslint/naming-convention
42- 'Microsoft.Web' : 'ms-azuretools.vscode-azurefunctions' ,
43- // eslint-disable-next-line @typescript-eslint/naming-convention
44- 'Microsoft.Storage' : 'ms-azuretools.vscode-azurestorage' ,
45- // eslint-disable-next-line @typescript-eslint/naming-convention
46- 'Microsoft.DocumentDB' : 'ms-azuretools.azure-cosmos' ,
47- } ;
48-
49- const extensionId = extensionMap [ provider ] ;
50- if ( extensionId ) {
51- ext . outputChannel . appendLog ( vscode . l10n . t ( 'Activating extension: {0}' , extensionId ) ) ;
52- const extension = vscode . extensions . getExtension ( extensionId ) ;
53- if ( extension && ! extension . isActive ) {
54- await extension . activate ( ) ;
55- ext . outputChannel . appendLog ( vscode . l10n . t ( 'Extension activated' ) ) ;
56- // Delay to allow the extension to register its tree data provider.
57- // The Azure Resources API doesn't provide an event for when provider registration completes.
58- await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
59- }
60- }
61- }
62-
63- ext . outputChannel . appendLog ( vscode . l10n . t ( 'Attempting reveal...' ) ) ;
6424
6525 try {
6626 // Try to refresh the Azure Resources view to ensure the tree is loaded
67- ext . outputChannel . appendLog ( vscode . l10n . t ( 'Refreshing Azure Resources tree...' ) ) ;
6827 try {
6928 await vscode . commands . executeCommand ( 'azureResourceGroups.refresh' ) ;
70- ext . outputChannel . appendLog ( vscode . l10n . t ( 'Refresh command executed' ) ) ;
7129 // Delay to allow the tree to fully populate after refresh.
7230 // The Azure Resources API doesn't expose an event for tree load completion,
7331 // so we use a delay as a pragmatic workaround.
7432 await new Promise ( resolve => setTimeout ( resolve , 1500 ) ) ;
7533 } catch ( refreshError ) {
76- ext . outputChannel . appendLog ( vscode . l10n . t ( 'Refresh command not available or failed: {0}' , refreshError instanceof Error ? refreshError . message : String ( refreshError ) ) ) ;
34+ ext . outputChannel . debug ( vscode . l10n . t ( 'Refresh command not available or failed: {0}' , refreshError instanceof Error ? refreshError . message : String ( refreshError ) ) ) ;
7735 }
7836
7937 // Extract subscription and resource group from the resource ID to reveal the RG first
8038 const resourceIdMatch = azureResourceId . match ( / \/ s u b s c r i p t i o n s \/ ( [ ^ / ] + ) \/ r e s o u r c e G r o u p s \/ ( [ ^ / ] + ) / i) ;
8139 if ( resourceIdMatch ) {
8240 const subscriptionId = resourceIdMatch [ 1 ] ;
8341 const resourceGroupName = resourceIdMatch [ 2 ] ;
84- ext . outputChannel . appendLog ( vscode . l10n . t ( 'Subscription: {0}, Resource Group: {1}' , subscriptionId , resourceGroupName ) ) ;
8542
8643 // Try revealing the resource group first to ensure the tree is expanded
8744 const rgResourceId = `/subscriptions/${ subscriptionId } /resourceGroups/${ resourceGroupName } ` ;
88- ext . outputChannel . appendLog ( vscode . l10n . t ( 'Revealing resource group first: {0}' , rgResourceId ) ) ;
8945 try {
9046 await api . resources . revealAzureResource ( rgResourceId , { select : false , focus : false , expand : true } ) ;
9147 // Delay to allow the tree node to expand before revealing the child resource.
9248 // The revealAzureResource API returns before the tree UI fully updates.
9349 await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
9450 } catch ( rgError ) {
95- ext . outputChannel . appendLog ( vscode . l10n . t ( 'Resource group reveal failed: {0}' , rgError instanceof Error ? rgError . message : String ( rgError ) ) ) ;
51+ ext . outputChannel . debug ( vscode . l10n . t ( 'Resource group reveal failed: {0}' , rgError instanceof Error ? rgError . message : String ( rgError ) ) ) ;
9652 }
9753 }
9854
99- ext . outputChannel . appendLog ( vscode . l10n . t ( 'Calling revealAzureResource with options: select=true, focus=true, expand=true' ) ) ;
10055 const result = await api . resources . revealAzureResource ( azureResourceId , { select : true , focus : true , expand : true } ) ;
101- ext . outputChannel . appendLog ( vscode . l10n . t ( 'revealAzureResource returned: {0}' , String ( result ) ) ) ;
10256
10357 // Note: The focusGroup command to trigger "Focused Resources" view requires internal
10458 // tree item context that's not accessible through the public API. Users can manually
10559 // click the zoom-in icon on the resource group if they want the focused view.
10660
10761 // Try a second time if needed
10862 if ( result === undefined ) {
109- ext . outputChannel . appendLog ( vscode . l10n . t ( 'First reveal returned undefined, trying again after delay...' ) ) ;
11063 // Retry delay: the first reveal may fail if the tree hasn't finished loading.
11164 // A brief delay before retry often succeeds where the first attempt failed.
11265 await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
11366 const secondResult = await api . resources . revealAzureResource ( azureResourceId , { select : true , focus : true , expand : true } ) ;
114- ext . outputChannel . appendLog ( vscode . l10n . t ( 'Second attempt returned: {0}' , String ( secondResult ) ) ) ;
11567
11668 // Try using the openInPortal command as an alternative
11769 if ( secondResult === undefined ) {
118- ext . outputChannel . appendLog ( vscode . l10n . t ( 'Reveal API not working as expected, trying alternative approach' ) ) ;
11970 // Try the workspace resource reveal command specific to this view
12071 try {
12172 await vscode . commands . executeCommand ( 'azureResourceGroups.revealResource' , azureResourceId ) ;
122- ext . outputChannel . appendLog ( vscode . l10n . t ( 'Alternative reveal command succeeded' ) ) ;
12373 } catch ( altError ) {
124- ext . outputChannel . appendLog ( vscode . l10n . t ( 'Alternative reveal also failed: {0}' , altError instanceof Error ? altError . message : String ( altError ) ) ) ;
74+ ext . outputChannel . debug ( vscode . l10n . t ( 'Alternative reveal also failed: {0}' , altError instanceof Error ? altError . message : String ( altError ) ) ) ;
12575 vscode . window . showInformationMessage (
12676 vscode . l10n . t ( 'Unable to automatically reveal resource in tree. Resource ID: {0}' , azureResourceId ) ,
12777 vscode . l10n . t ( 'Copy Resource ID' ) ,
@@ -136,11 +86,8 @@ export class RevealStep extends AzureWizardExecuteStep<RevealResourceWizardConte
13686 }
13787 }
13888 }
139-
140- ext . outputChannel . appendLog ( vscode . l10n . t ( 'revealAzureResource completed' ) ) ;
14189 } catch ( error ) {
142- ext . outputChannel . appendLog ( vscode . l10n . t ( 'Failed to reveal resource: {0}' , error instanceof Error ? error . message : String ( error ) ) ) ;
143- // Show error to user
90+ ext . outputChannel . error ( vscode . l10n . t ( 'Failed to reveal resource: {0}' , error instanceof Error ? error . message : String ( error ) ) ) ;
14491 vscode . window . showErrorMessage ( vscode . l10n . t ( 'Failed to reveal Azure resource: {0}' , error instanceof Error ? error . message : String ( error ) ) ) ;
14592 throw error ;
14693 }
0 commit comments