@@ -418,31 +418,44 @@ export class Commands {
418418 } ) : Promise < void > {
419419 // Launch and run command in terminal if command is provided
420420 if ( app . command ) {
421- const terminal = vscode . window . createTerminal ( app . status )
422- vscode . commands . executeCommand ( "workbench.action.toggleMaximizedPanel" )
423- // If workspace_name is provided, run coder ssh before the command
424- if ( app . workspace_name ) {
425- let url = this . storage . getUrl ( )
426- if ( ! url ) {
427- throw new Error ( "No coder url found for sidebar" ) ;
421+ return vscode . window . withProgress ( {
422+ location : vscode . ProgressLocation . Notification ,
423+ title : `Launching ${ app . name || "application" } ...` ,
424+ cancellable : false
425+ } , async ( ) => {
426+ const terminal = vscode . window . createTerminal ( app . status )
427+
428+ // If workspace_name is provided, run coder ssh before the command
429+ if ( app . workspace_name ) {
430+ let url = this . storage . getUrl ( )
431+ if ( ! url ) {
432+ throw new Error ( "No coder url found for sidebar" ) ;
433+ }
434+ let binary = await this . storage . fetchBinary ( this . restClient , toSafeHost ( url ) )
435+ const escape = ( str : string ) : string => `"${ str . replace ( / " / g, '\\"' ) } "`
436+ terminal . sendText ( `${ escape ( binary ) } ssh --global-config ${ escape (
437+ path . dirname ( this . storage . getSessionTokenPath ( toSafeHost ( url ) ) ) ,
438+ ) } ${ app . workspace_name } `)
439+ await new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) )
440+ terminal . sendText ( app . command ?? "" )
441+ } else {
442+ terminal . sendText ( "need workspace name" )
428443 }
429- let binary = await this . storage . fetchBinary ( this . restClient , toSafeHost ( url ) )
430- const escape = ( str : string ) : string => `"${ str . replace ( / " / g, '\\"' ) } "`
431- terminal . sendText ( `${ escape ( binary ) } ssh --global-config ${ escape (
432- path . dirname ( this . storage . getSessionTokenPath ( toSafeHost ( url ) ) ) ,
433- ) } ${ app . workspace_name } `)
434- await new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) )
435- terminal . sendText ( app . command )
436- } else {
437- terminal . sendText ( "need workspace name" )
438- }
439- terminal . show ( false )
440- return
444+
445+ // Maximise the terminal and switch focus to the launch terminal window.
446+ vscode . commands . executeCommand ( "workbench.action.toggleMaximizedPanel" )
447+ terminal . show ( false )
448+ } ) ;
441449 }
442450 // Check if app has a URL to open
443451 if ( app . url ) {
444- await vscode . env . openExternal ( vscode . Uri . parse ( app . url ) )
445- return
452+ return vscode . window . withProgress ( {
453+ location : vscode . ProgressLocation . Notification ,
454+ title : `Opening ${ app . name || "application" } in browser...` ,
455+ cancellable : false
456+ } , async ( ) => {
457+ await vscode . env . openExternal ( vscode . Uri . parse ( app . url ! ) )
458+ } ) ;
446459 }
447460
448461 // If no URL or command, show information about the app status
0 commit comments