Skip to content

Commit ebbc659

Browse files
committed
Report linux desktop-related env vars in issue reporter
Fixes microsoft#94388
1 parent 5b0460a commit ebbc659

4 files changed

Lines changed: 75 additions & 3 deletions

File tree

src/vs/code/electron-browser/issue/issueReporterModel.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ ${this.getInfos()}
168168
|Screen Reader|${this._data.systemInfo.screenReader}|
169169
|VM|${this._data.systemInfo.vmHint}|`;
170170

171+
if (this._data.systemInfo.linuxEnv) {
172+
md += `\n|DESKTOP_SESSION|${this._data.systemInfo.linuxEnv.desktopSession}|
173+
|XDG_CURRENT_DESKTOP|${this._data.systemInfo.linuxEnv.xdgCurrentDesktop}|
174+
|XDG_SESSION_DESKTOP|${this._data.systemInfo.linuxEnv.xdgSessionDesktop}|
175+
|XDG_SESSION_TYPE|${this._data.systemInfo.linuxEnv.xdgSessionType}|`;
176+
}
177+
171178
this._data.systemInfo.remoteData.forEach(remote => {
172179
if (isRemoteDiagnosticError(remote)) {
173180
md += `\n\n${remote.errorMessage}`;
@@ -268,4 +275,4 @@ ${table}
268275
269276
</details>`;
270277
}
271-
}
278+
}

src/vs/code/electron-browser/issue/test/testReporterModel.test.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,55 @@ OS version: undefined
8181
<!-- generated by issue reporter -->`);
8282
});
8383

84+
test('serializes Linux environment information when data is provided', () => {
85+
const issueReporterModel = new IssueReporterModel({
86+
issueType: 0,
87+
systemInfo: {
88+
os: 'Darwin',
89+
cpus: 'Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2800)',
90+
memory: '16.00GB',
91+
vmHint: '0%',
92+
processArgs: '',
93+
screenReader: 'no',
94+
remoteData: [],
95+
gpuStatus: {},
96+
linuxEnv: {
97+
desktopSession: 'ubuntu',
98+
xdgCurrentDesktop: 'ubuntu',
99+
xdgSessionDesktop: 'ubuntu:GNOME',
100+
xdgSessionType: 'x11'
101+
}
102+
}
103+
});
104+
assert.equal(issueReporterModel.serialize(),
105+
`
106+
Issue Type: <b>Bug</b>
107+
108+
undefined
109+
110+
VS Code version: undefined
111+
OS version: undefined
112+
113+
<details>
114+
<summary>System Info</summary>
115+
116+
|Item|Value|
117+
|---|---|
118+
|CPUs|Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2800)|
119+
|GPU Status||
120+
|Load (avg)|undefined|
121+
|Memory (System)|16.00GB|
122+
|Process Argv||
123+
|Screen Reader|no|
124+
|VM|0%|
125+
|DESKTOP_SESSION|ubuntu|
126+
|XDG_CURRENT_DESKTOP|ubuntu|
127+
|XDG_SESSION_DESKTOP|ubuntu:GNOME|
128+
|XDG_SESSION_TYPE|x11|
129+
</details>Extensions: none
130+
<!-- generated by issue reporter -->`);
131+
});
132+
84133
test('serializes remote information when data is provided', () => {
85134
const issueReporterModel = new IssueReporterModel({
86135
issueType: 0,

src/vs/platform/diagnostics/common/diagnostics.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ export interface IMachineInfo {
1313
cpus?: string;
1414
memory: string;
1515
vmHint: string;
16+
linuxEnv?: ILinuxEnv;
17+
}
18+
19+
export interface ILinuxEnv {
20+
desktopSession?: string;
21+
xdgSessionDesktop?: string;
22+
xdgCurrentDesktop?: string;
23+
xdgSessionType?: string;
1624
}
1725

1826
export interface IDiagnosticInfo {

src/vs/platform/diagnostics/node/diagnosticsService.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { parse, ParseError, getNodeType } from 'vs/base/common/json';
1111
import { listProcesses } from 'vs/base/node/ps';
1212
import product from 'vs/platform/product/common/product';
1313
import { repeat, pad } from 'vs/base/common/strings';
14-
import { isWindows } from 'vs/base/common/platform';
14+
import { isWindows, isLinux } from 'vs/base/common/platform';
1515
import { URI } from 'vs/base/common/uri';
1616
import { ProcessItem } from 'vs/base/common/processes';
1717
import { IMainProcessInfo } from 'vs/platform/launch/common/launch';
@@ -336,11 +336,19 @@ export class DiagnosticsService implements IDiagnosticsService {
336336
remoteData
337337
};
338338

339-
340339
if (!isWindows) {
341340
systemInfo.load = `${osLib.loadavg().map(l => Math.round(l)).join(', ')}`;
342341
}
343342

343+
if (isLinux) {
344+
systemInfo.linuxEnv = {
345+
desktopSession: process.env.DESKTOP_SESSION,
346+
xdgSessionDesktop: process.env.XDG_SESSION_DESKTOP,
347+
xdgCurrentDesktop: process.env.XDG_CURRENT_DESKTOP,
348+
xdgSessionType: process.env.XDG_SESSION_TYPE
349+
};
350+
}
351+
344352
return Promise.resolve(systemInfo);
345353
}
346354

0 commit comments

Comments
 (0)