@@ -7,7 +7,7 @@ import * as vscode from 'vscode';
77import { Command } from '../commandManager' ;
88import { ISessionService } from '../services/sessionService' ;
99import { WorkspaceData , rawWorkspaceToWorkspaceData } from '../publicApi' ;
10- import { SSHConnectionParams , SSH_DEST_KEY , getLocalSSHDomain } from '../remote' ;
10+ import { SSHConnectionParams , SSH_DEST_KEY , getGitpodRemoteWindowConnectionInfo , getLocalSSHDomain } from '../remote' ;
1111import SSHDestination from '../ssh/sshDestination' ;
1212import { IHostService } from '../services/hostService' ;
1313import { WorkspaceState } from '../workspaceState' ;
@@ -493,25 +493,26 @@ export class StopCurrentWorkspaceCommand implements Command {
493493 readonly id : string = 'gitpod.workspaces.stopCurrentWorkspace' ;
494494
495495 constructor (
496- private readonly workspaceId : string | undefined ,
496+ private readonly context : vscode . ExtensionContext ,
497497 private readonly sessionService : ISessionService ,
498498 private readonly hostService : IHostService ,
499499 private readonly telemetryService : ITelemetryService ,
500500 ) { }
501501
502502 async execute ( ) {
503- if ( ! this . workspaceId ) {
503+ const workspaceId = getGitpodRemoteWindowConnectionInfo ( this . context ) ?. connectionInfo . workspaceId ;
504+ if ( ! workspaceId ) {
504505 return ;
505506 }
506507
507508 this . telemetryService . sendTelemetryEvent ( 'vscode_desktop_view_command' , {
508509 name : getCommandName ( this . id ) ,
509510 gitpodHost : this . hostService . gitpodHost ,
510- workspaceId : this . workspaceId ,
511+ workspaceId : workspaceId ,
511512 location : 'commandPalette'
512513 } ) ;
513514
514- await this . sessionService . getAPI ( ) . stopWorkspace ( this . workspaceId ) ;
515+ await this . sessionService . getAPI ( ) . stopWorkspace ( workspaceId ) ;
515516 await vscode . commands . executeCommand ( 'workbench.action.remote.close' ) ;
516517 }
517518}
@@ -520,36 +521,33 @@ export class StopCurrentWorkspaceCommandInline extends StopCurrentWorkspaceComma
520521 override readonly id = 'gitpod.workspaces.stopCurrentWorkspace_inline' ;
521522
522523 constructor (
523- workspaceId : string | undefined ,
524+ context : vscode . ExtensionContext ,
524525 sessionService : ISessionService ,
525526 hostService : IHostService ,
526527 telemetryService : ITelemetryService ,
527528 ) {
528- super ( workspaceId , sessionService , hostService , telemetryService ) ;
529+ super ( context , sessionService , hostService , telemetryService ) ;
529530 }
530531}
531532
532533export class OpenInBrowserCommand implements Command {
533534 readonly id = 'gitpod.workspaces.openInBrowser' ;
534535
535536 constructor (
537+ private readonly context : vscode . ExtensionContext ,
536538 private readonly sessionService : ISessionService ,
537539 private readonly hostService : IHostService ,
538540 private readonly telemetryService : ITelemetryService ,
539541 ) { }
540542
541543 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 ) {
550546 return ;
551547 }
552548
549+ const wsData = rawWorkspaceToWorkspaceData ( await this . sessionService . getAPI ( ) . getWorkspace ( workspaceId ) ) ;
550+
553551 this . telemetryService . sendTelemetryEvent ( 'vscode_desktop_view_command' , {
554552 name : getCommandName ( this . id ) ,
555553 gitpodHost : this . hostService . gitpodHost ,
@@ -616,18 +614,20 @@ export class OpenWorkspaceContextCommand implements Command {
616614 readonly id = 'gitpod.workspaces.openContext' ;
617615
618616 constructor (
617+ private readonly context : vscode . ExtensionContext ,
619618 private readonly sessionService : ISessionService ,
620619 private readonly hostService : IHostService ,
621620 private readonly telemetryService : ITelemetryService ,
622621 ) { }
623622
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 ) {
626626 return ;
627627 }
628628
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 ) ) ;
631631
632632 // Report if we couldn't parse contextUrl
633633 if ( ! wsData . contextUrl ) {
0 commit comments