Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional env vars for more metadata about the Positron session #4703

Merged
merged 8 commits into from
Sep 19, 2024
7 changes: 6 additions & 1 deletion extensions/jupyter-adapter/src/JupyterKernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,12 @@ export class JupyterKernel extends EventEmitter implements vscode.Disposable {
const command = args.join(' ');

// Create environment.
const env = { POSITRON: '1', POSITRON_VERSION: positron.version };
const env = {
POSITRON: '1',
POSITRON_VERSION: positron.version,
POSITRON_LONG_VERSION: `${positron.version}+${positron.buildNumber}`,
POSITRON_MODE: vscode.env.uiKind === vscode.UIKind.Desktop ? 'desktop' : 'server',
};
Object.assign(env, process.env, this._spec.env);

// We are now starting the kernel
Expand Down
2 changes: 1 addition & 1 deletion extensions/positron-r/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@
},
"positron": {
"binaryDependencies": {
"ark": "0.1.136"
"ark": "0.1.138"
},
"minimumRVersion": "4.2.0",
"minimumRenvVersion": "1.0.7"
Expand Down
10 changes: 9 additions & 1 deletion src/vs/platform/terminal/node/terminalEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ import { EnvironmentVariableMutatorType } from 'vs/platform/terminal/common/envi
import { deserializeEnvironmentVariableCollections } from 'vs/platform/terminal/common/environmentVariableShared';
import { MergedEnvironmentVariableCollection } from 'vs/platform/terminal/common/environmentVariableCollection';

// --- Start Positron ---
// eslint-disable-next-line no-duplicate-imports
import { isWeb } from 'vs/base/common/platform';
// --- End Positron ---

export function getWindowsBuildNumber(): number {
const osVersion = (/(\d+)\.(\d+)\.(\d+)/g).exec(os.release());
let buildNumber: number = 0;
Expand Down Expand Up @@ -140,7 +145,10 @@ export function getShellIntegrationInjection(
// --- Start Positron ---
// 'VSCODE_INJECTION': '1'
'VSCODE_INJECTION': '1',
'POSITRON': '1'
'POSITRON': '1',
'POSITRON_VERSION': productService.positronVersion,
'POSITRON_LONG_VERSION': `${productService.positronVersion}+${productService.positronBuildNumber}`,
'POSITRON_MODE': isWeb ? 'server' : 'desktop'
// --- End Positron ---
};

Expand Down
19 changes: 18 additions & 1 deletion src/vs/platform/terminal/test/node/terminalEnvironment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import { IProductService } from 'vs/platform/product/common/productService';
import { ITerminalProcessOptions } from 'vs/platform/terminal/common/terminal';
import { getShellIntegrationInjection, getWindowsBuildNumber, IShellIntegrationConfigInjection } from 'vs/platform/terminal/node/terminalEnvironment';

// --- Start Positron ---
// eslint-disable-next-line no-duplicate-imports
import { isWeb } from 'vs/base/common/platform';
// --- End Positron ---

const enabledProcessOptions: ITerminalProcessOptions = { shellIntegration: { enabled: true, suggestEnabled: false, nonce: '' }, windowsEnableConpty: true, windowsUseConptyDll: false, environmentVariableCollections: undefined, workspaceFolder: undefined };
const disabledProcessOptions: ITerminalProcessOptions = { shellIntegration: { enabled: false, suggestEnabled: false, nonce: '' }, windowsEnableConpty: true, windowsUseConptyDll: false, environmentVariableCollections: undefined, workspaceFolder: undefined };
const winptyProcessOptions: ITerminalProcessOptions = { shellIntegration: { enabled: true, suggestEnabled: false, nonce: '' }, windowsEnableConpty: false, windowsUseConptyDll: false, environmentVariableCollections: undefined, workspaceFolder: undefined };
Expand Down Expand Up @@ -52,6 +57,9 @@ suite('platform - terminalEnvironment', () => {
envMixin: {
// --- Start Positron ---
POSITRON: '1',
POSITRON_VERSION: productService.positronVersion,
POSITRON_LONG_VERSION: `${productService.positronVersion}+${productService.positronBuildNumber}`,
POSITRON_MODE: isWeb ? 'server' : 'desktop',
// --- End Positron ---
VSCODE_INJECTION: '1'
}
Expand Down Expand Up @@ -86,6 +94,9 @@ suite('platform - terminalEnvironment', () => {
envMixin: {
// --- Start Positron ---
POSITRON: '1',
POSITRON_VERSION: productService.positronVersion,
POSITRON_LONG_VERSION: `${productService.positronVersion}+${productService.positronBuildNumber}`,
POSITRON_MODE: isWeb ? 'server' : 'desktop',
// --- End Positron ---
VSCODE_INJECTION: '1'
}
Expand Down Expand Up @@ -133,7 +144,7 @@ suite('platform - terminalEnvironment', () => {
function assertIsEnabled(result: IShellIntegrationConfigInjection, globalZdotdir = homedir()) {
// --- Start Positron ---
// strictEqual(Object.keys(result.envMixin!).length, 3);
strictEqual(Object.keys(result.envMixin!).length, 4);
strictEqual(Object.keys(result.envMixin!).length, 7);
// --- End Positron ---
ok(result.envMixin!['ZDOTDIR']?.match(expectedDir));
strictEqual(result.envMixin!['USER_ZDOTDIR'], globalZdotdir);
Expand Down Expand Up @@ -200,6 +211,9 @@ suite('platform - terminalEnvironment', () => {
envMixin: {
// --- Start Positron ---
POSITRON: '1',
POSITRON_VERSION: productService.positronVersion,
POSITRON_LONG_VERSION: `${productService.positronVersion}+${productService.positronBuildNumber}`,
POSITRON_MODE: isWeb ? 'server' : 'desktop',
// --- End Positron ---
VSCODE_INJECTION: '1',
VSCODE_STABLE: '0'
Expand All @@ -218,6 +232,9 @@ suite('platform - terminalEnvironment', () => {
envMixin: {
// --- Start Positron ---
POSITRON: '1',
POSITRON_VERSION: productService.positronVersion,
POSITRON_LONG_VERSION: `${productService.positronVersion}+${productService.positronBuildNumber}`,
POSITRON_MODE: isWeb ? 'server' : 'desktop',
// --- End Positron ---
VSCODE_INJECTION: '1',
VSCODE_SHELL_LOGIN: '1',
Expand Down