diff --git a/package.json b/package.json index dd190f9..ae8e1ea 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "Gitpod", "description": "Gitpod Support", "publisher": "gitpod", - "version": "0.0.172", + "version": "0.0.173", "license": "MIT", "icon": "resources/gitpod.png", "repository": { @@ -270,16 +270,20 @@ ], "commandPalette": [ { - "command": "gitpod.workspaces.refresh", - "when": "false" + "command": "gitpod.signIn", + "when": "!gitpod.inGpNextRemoteWindow" + }, + { + "command": "gitpod.exportLogs", + "when": "!gitpod.inGpNextRemoteWindow" }, { "command": "gitpod.workspaces.refresh", - "when": "gitpod.authenticated == true" + "when": "gitpod.authenticated == true && !gitpod.inGpNextRemoteWindow" }, { "command": "gitpod.workspaces.connectInNewWindow", - "when": "gitpod.authenticated == true" + "when": "gitpod.authenticated == true && !gitpod.inGpNextRemoteWindow" }, { "command": "gitpod.workspaces.connectInNewWindow_context", @@ -287,7 +291,7 @@ }, { "command": "gitpod.workspaces.connectInCurrentWindow", - "when": "gitpod.authenticated == true" + "when": "gitpod.authenticated == true && !gitpod.inGpNextRemoteWindow" }, { "command": "gitpod.workspaces.connectInCurrentWindow_context", @@ -307,7 +311,7 @@ }, { "command": "gitpod.workspaces.stopWorkspace", - "when": "gitpod.authenticated == true && gitpod.inWorkspace != true" + "when": "gitpod.authenticated == true && gitpod.inWorkspace != true && !gitpod.inGpNextRemoteWindow" }, { "command": "gitpod.workspaces.stopWorkspace_context", @@ -335,7 +339,7 @@ }, { "command": "gitpod.workspaces.deleteWorkspace", - "when": "gitpod.authenticated == true && gitpod.inWorkspace != true" + "when": "gitpod.authenticated == true && gitpod.inWorkspace != true && !gitpod.inGpNextRemoteWindow" }, { "command": "gitpod.workspaces.deleteWorkspace_context", @@ -362,13 +366,13 @@ "id": "gitpod-login", "name": "Login", "icon": "$(squirrel)", - "when": "gitpod.authenticated != true" + "when": "gitpod.authenticated != true && !gitpod.inGpNextRemoteWindow" }, { "id": "gitpod-workspaces", "name": "Workspaces", "icon": "$(squirrel)", - "when": "gitpod.authenticated == true" + "when": "gitpod.authenticated == true && !gitpod.inGpNextRemoteWindow" }, { "id": "gitpod-workspace", @@ -381,7 +385,7 @@ "viewsWelcome": [ { "view": "gitpod-login", - "when": "gitpod.authenticated != true", + "when": "gitpod.authenticated != true && !gitpod.inGpNextRemoteWindow", "contents": "You have not yet signed in with Gitpod\n[Sign in](command:gitpod.signIn)" } ] diff --git a/src/extension.ts b/src/extension.ts index 558bb49..24835fd 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -13,7 +13,7 @@ import { NotificationService } from './services/notificationService'; import { RemoteConnector } from './remoteConnector'; import { TelemetryService } from './services/telemetryService'; import { RemoteSession } from './remoteSession'; -import { SSHConnectionParams, getGitpodRemoteWindowConnectionInfo } from './remote'; +import { SSHConnectionParams, getGitpodRemoteWindowConnectionInfo, isGitpodNextRemoteWindow } from './remote'; import { HostService } from './services/hostService'; import { SessionService } from './services/sessionService'; import { CommandManager } from './commandManager'; @@ -45,6 +45,11 @@ export async function activate(context: vscode.ExtensionContext) { const extensionId = context.extension.id; const packageJSON = context.extension.packageJSON; + if (isGitpodNextRemoteWindow()) { + vscode.commands.executeCommand('setContext', 'gitpod.inGpNextRemoteWindow', true); + return; + } + let remoteConnectionInfo: { connectionInfo: SSHConnectionParams; remoteUri: vscode.Uri; sshDestStr: string } | undefined; let success = false; try { diff --git a/src/remote.ts b/src/remote.ts index 10253d1..f5db8aa 100644 --- a/src/remote.ts +++ b/src/remote.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; +import SSHDestination from './ssh/sshDestination'; export interface SSHConnectionParams { workspaceId: string; @@ -69,6 +70,35 @@ export function getGitpodRemoteWindowConnectionInfo(context: vscode.ExtensionCon return undefined; } +export function isGitpodNextRemoteWindow() { + const remoteUri = vscode.workspace.workspaceFile?.scheme !== 'untitled' + ? vscode.workspace.workspaceFile || vscode.workspace.workspaceFolders?.[0].uri + : vscode.workspace.workspaceFolders?.[0].uri; + if (!remoteUri) { + return false; + } + if (vscode.env.remoteName === 'dev-container') { + const authorities = remoteUri.authority.split('@'); + const sshAuthority = authorities.find((str) => str.includes('ssh-remote')); + const containerAuthority = authorities.find((str) => str.includes('dev-container')); + if (!sshAuthority || !containerAuthority) { + return false; + } + const [, sshEncoded] = sshAuthority.split('+'); + if (!sshEncoded) { + return false; + } + const [, containerEncoded] = containerAuthority.split('+'); + if (!containerEncoded) { + return false; + } + const sshDest = SSHDestination.fromRemoteSSHString(sshEncoded); + + return /gitpod\.(local|remote)$/.test(sshDest.hostname); + } + return false; +} + export function getLocalSSHDomain(gitpodHost: string): string { const scope = vscode.env.appName.includes('Insiders') ? 'vsi' : 'vss'; return `${scope}.` + (new URL(gitpodHost)).hostname;