@@ -7,7 +7,7 @@ import * as vscode from 'vscode';
7
7
import { Command } from '../commandManager' ;
8
8
import { ISessionService } from '../services/sessionService' ;
9
9
import { WorkspaceData , rawWorkspaceToWorkspaceData } from '../publicApi' ;
10
- import { SSHConnectionParams , SSH_DEST_KEY , getLocalSSHDomain } from '../remote' ;
10
+ import { SSHConnectionParams , SSH_DEST_KEY , getGitpodRemoteWindowConnectionInfo , getLocalSSHDomain } from '../remote' ;
11
11
import SSHDestination from '../ssh/sshDestination' ;
12
12
import { IHostService } from '../services/hostService' ;
13
13
import { WorkspaceState } from '../workspaceState' ;
@@ -493,25 +493,26 @@ export class StopCurrentWorkspaceCommand implements Command {
493
493
readonly id : string = 'gitpod.workspaces.stopCurrentWorkspace' ;
494
494
495
495
constructor (
496
- private readonly workspaceId : string | undefined ,
496
+ private readonly context : vscode . ExtensionContext ,
497
497
private readonly sessionService : ISessionService ,
498
498
private readonly hostService : IHostService ,
499
499
private readonly telemetryService : ITelemetryService ,
500
500
) { }
501
501
502
502
async execute ( ) {
503
- if ( ! this . workspaceId ) {
503
+ const workspaceId = getGitpodRemoteWindowConnectionInfo ( this . context ) ?. connectionInfo . workspaceId ;
504
+ if ( ! workspaceId ) {
504
505
return ;
505
506
}
506
507
507
508
this . telemetryService . sendTelemetryEvent ( 'vscode_desktop_view_command' , {
508
509
name : getCommandName ( this . id ) ,
509
510
gitpodHost : this . hostService . gitpodHost ,
510
- workspaceId : this . workspaceId ,
511
+ workspaceId : workspaceId ,
511
512
location : 'commandPalette'
512
513
} ) ;
513
514
514
- await this . sessionService . getAPI ( ) . stopWorkspace ( this . workspaceId ) ;
515
+ await this . sessionService . getAPI ( ) . stopWorkspace ( workspaceId ) ;
515
516
await vscode . commands . executeCommand ( 'workbench.action.remote.close' ) ;
516
517
}
517
518
}
@@ -520,36 +521,33 @@ export class StopCurrentWorkspaceCommandInline extends StopCurrentWorkspaceComma
520
521
override readonly id = 'gitpod.workspaces.stopCurrentWorkspace_inline' ;
521
522
522
523
constructor (
523
- workspaceId : string | undefined ,
524
+ context : vscode . ExtensionContext ,
524
525
sessionService : ISessionService ,
525
526
hostService : IHostService ,
526
527
telemetryService : ITelemetryService ,
527
528
) {
528
- super ( workspaceId , sessionService , hostService , telemetryService ) ;
529
+ super ( context , sessionService , hostService , telemetryService ) ;
529
530
}
530
531
}
531
532
532
533
export class OpenInBrowserCommand implements Command {
533
534
readonly id = 'gitpod.workspaces.openInBrowser' ;
534
535
535
536
constructor (
537
+ private readonly context : vscode . ExtensionContext ,
536
538
private readonly sessionService : ISessionService ,
537
539
private readonly hostService : IHostService ,
538
540
private readonly telemetryService : ITelemetryService ,
539
541
) { }
540
542
541
543
async execute ( treeItem ?: { id : string } ) {
542
- let wsData : WorkspaceData | undefined ;
543
- if ( ! treeItem ?. id ) {
544
- wsData = ( await showWorkspacesPicker ( this . sessionService , 'Select a workspace to connect...' ) ) ;
545
- } else {
546
- wsData = rawWorkspaceToWorkspaceData ( await this . sessionService . getAPI ( ) . getWorkspace ( treeItem . id ) ) ;
547
- }
548
-
549
- if ( ! wsData ) {
544
+ let workspaceId = treeItem ?. id || getGitpodRemoteWindowConnectionInfo ( this . context ) ?. connectionInfo . workspaceId ;
545
+ if ( ! workspaceId ) {
550
546
return ;
551
547
}
552
548
549
+ const wsData = rawWorkspaceToWorkspaceData ( await this . sessionService . getAPI ( ) . getWorkspace ( workspaceId ) ) ;
550
+
553
551
this . telemetryService . sendTelemetryEvent ( 'vscode_desktop_view_command' , {
554
552
name : getCommandName ( this . id ) ,
555
553
gitpodHost : this . hostService . gitpodHost ,
@@ -616,18 +614,20 @@ export class OpenWorkspaceContextCommand implements Command {
616
614
readonly id = 'gitpod.workspaces.openContext' ;
617
615
618
616
constructor (
617
+ private readonly context : vscode . ExtensionContext ,
619
618
private readonly sessionService : ISessionService ,
620
619
private readonly hostService : IHostService ,
621
620
private readonly telemetryService : ITelemetryService ,
622
621
) { }
623
622
624
- async execute ( treeItem : { id : string } ) {
625
- if ( ! treeItem ?. id ) {
623
+ async execute ( treeItem ?: { id : string } ) {
624
+ let workspaceId = treeItem ?. id || getGitpodRemoteWindowConnectionInfo ( this . context ) ?. connectionInfo . workspaceId ;
625
+ if ( ! workspaceId ) {
626
626
return ;
627
627
}
628
628
629
- const rawWsData = await this . sessionService . getAPI ( ) . getWorkspace ( treeItem . id ) ;
630
- const wsData = rawWorkspaceToWorkspaceData ( await this . sessionService . getAPI ( ) . getWorkspace ( treeItem . id ) ) ;
629
+ const rawWsData = await this . sessionService . getAPI ( ) . getWorkspace ( workspaceId ) ;
630
+ const wsData = rawWorkspaceToWorkspaceData ( await this . sessionService . getAPI ( ) . getWorkspace ( workspaceId ) ) ;
631
631
632
632
// Report if we couldn't parse contextUrl
633
633
if ( ! wsData . contextUrl ) {
0 commit comments