fix: sanitize sidecar launch environment

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Copilot CLI
2026-03-21 10:35:55 +01:00
co-authored by Copilot
parent 8f9eb99f3f
commit 2fbb5dc5a5
3 changed files with 53 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
import { describe, expect, test } from 'bun:test';
import { createSidecarEnvironment } from '@main/sidecar/sidecarEnvironment';
describe('createSidecarEnvironment', () => {
test('removes inherited Copilot loader variables before spawning the sidecar', () => {
expect(
createSidecarEnvironment({
PATH: 'C:\\tools',
COPILOT_CLI: '1',
COPILOT_LOADER_PID: '1234',
copilot_run_app: '1',
NODE_OPTIONS: '--no-warnings',
electron_run_as_node: '1',
}),
).toEqual({
PATH: 'C:\\tools',
});
});
test('preserves unrelated environment variables', () => {
expect(
createSidecarEnvironment({
PATH: 'C:\\tools',
HOME: 'C:\\Users\\mail',
FORCE_COLOR: '1',
}),
).toEqual({
PATH: 'C:\\tools',
HOME: 'C:\\Users\\mail',
FORCE_COLOR: '1',
});
});
});