Skip to content

Commit 206853c

Browse files
authored
dialogs: Clean up Copilot canary versions (#335096)
Remove the canary and unsigned markers when presenting Copilot runtime and SDK versions in the About dialog.\n\n(Written by Copilot)\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9387003 commit 206853c

2 files changed

Lines changed: 80 additions & 2 deletions

File tree

‎src/vs/platform/dialogs/electron-browser/dialog.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import { IOSProperties } from '../../native/common/native.js';
1010
import { IProductService } from '../../product/common/productService.js';
1111
import { process } from '../../../base/parts/sandbox/electron-browser/globals.js';
1212

13+
function formatCopilotVersion(version: string | undefined): string {
14+
return version?.replace('-canary', '').replace(/\.unsigned$/, '') || 'Unknown';
15+
}
16+
1317
export function createNativeAboutDialogDetails(productService: IProductService, osProps: IOSProperties): { title: string; details: string; detailsToCopy: string } {
1418
let version = productService.version;
1519
if (productService.target) {
@@ -18,6 +22,9 @@ export function createNativeAboutDialogDetails(productService: IProductService,
1822
version = `${version} (Universal)`;
1923
}
2024

25+
const copilotRuntimeVersion = formatCopilotVersion(productService.copilotVersions?.runtime);
26+
const copilotSdkVersion = formatCopilotVersion(productService.copilotVersions?.sdk);
27+
2128
const getDetails = (useAgo: boolean): string => {
2229
return localize({ key: 'aboutDetail', comment: ['Electron, Chromium, Node.js, V8 and Copilot are product names that need no translation'] },
2330
"Version: {0}\nCommit: {1}\nDate: {2}\nElectron: {3}\nElectronBuildId: {4}\nChromium: {5}\nNode.js: {6}\nV8: {7}\n@github/copilot: {8}\n@github/copilot-sdk: {9}\nOS: {10}",
@@ -29,8 +36,8 @@ export function createNativeAboutDialogDetails(productService: IProductService,
2936
process.versions['chrome'],
3037
process.versions['node'],
3138
process.versions['v8'],
32-
productService.copilotVersions?.runtime || 'Unknown',
33-
productService.copilotVersions?.sdk || 'Unknown',
39+
copilotRuntimeVersion,
40+
copilotSdkVersion,
3441
`${osProps.type} ${osProps.arch} ${osProps.release}${isLinuxSnap ? ' snap' : ''}`
3542
);
3643
};
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import assert from 'assert';
7+
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js';
8+
import { IOSProperties } from '../../../native/common/native.js';
9+
import product from '../../../product/common/product.js';
10+
import { IProductService } from '../../../product/common/productService.js';
11+
import { createNativeAboutDialogDetails } from '../../electron-browser/dialog.js';
12+
13+
suite('Dialog', () => {
14+
15+
ensureNoDisposablesAreLeakedInTestSuite();
16+
17+
const osProperties: IOSProperties = {
18+
type: 'Test OS',
19+
release: '1.0',
20+
arch: 'test-arch',
21+
platform: 'test',
22+
cpus: []
23+
};
24+
25+
function getCopilotVersionLines(runtime: string, sdk: string): { details: string[]; detailsToCopy: string[] } {
26+
const productService: IProductService = {
27+
_serviceBrand: undefined,
28+
...product,
29+
copilotVersions: { runtime, sdk }
30+
};
31+
const { details, detailsToCopy } = createNativeAboutDialogDetails(productService, osProperties);
32+
const selectCopilotVersionLines = (value: string) => value.split('\n').filter(line => line.startsWith('@github/copilot'));
33+
34+
return {
35+
details: selectCopilotVersionLines(details),
36+
detailsToCopy: selectCopilotVersionLines(detailsToCopy)
37+
};
38+
}
39+
40+
test('formats Copilot canary versions', () => {
41+
assert.deepStrictEqual(
42+
getCopilotVersionLines('1.0.84-canary.70.gdb75d0d.unsigned', '0.1.23-canary.45.gabcdef.unsigned'),
43+
{
44+
details: [
45+
'@github/copilot: 1.0.84.70.gdb75d0d',
46+
'@github/copilot-sdk: 0.1.23.45.gabcdef'
47+
],
48+
detailsToCopy: [
49+
'@github/copilot: 1.0.84.70.gdb75d0d',
50+
'@github/copilot-sdk: 0.1.23.45.gabcdef'
51+
]
52+
}
53+
);
54+
});
55+
56+
test('preserves stable Copilot versions', () => {
57+
assert.deepStrictEqual(
58+
getCopilotVersionLines('1.0.84', '0.1.23'),
59+
{
60+
details: [
61+
'@github/copilot: 1.0.84',
62+
'@github/copilot-sdk: 0.1.23'
63+
],
64+
detailsToCopy: [
65+
'@github/copilot: 1.0.84',
66+
'@github/copilot-sdk: 0.1.23'
67+
]
68+
}
69+
);
70+
});
71+
});

0 commit comments

Comments
 (0)