mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-07-09 17:29:12 +00:00
fix: hide the background updater console window on Windows (#1336)
A detached Windows child gets its own console window. With the shell: true introduced for the CVE-2024-27980 fix, a passive background auto-update could flash a command window even though stdio is ignored. Set windowsHide on the detached background child so the silent updater stays silent. The foreground `kimi upgrade` path is interactive (stdio: inherit, non-detached) and reuses the parent console, so it is left unchanged.
This commit is contained in:
parent
93f16c32d7
commit
4c1d0a1633
3 changed files with 30 additions and 0 deletions
5
.changeset/fix-windows-update-console-flash.md
Normal file
5
.changeset/fix-windows-update-console-flash.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@moonshot-ai/kimi-code": patch
|
||||
---
|
||||
|
||||
Keep automatic background updates from flashing a console window on Windows.
|
||||
|
|
@ -607,6 +607,10 @@ async function startBackgroundInstall(
|
|||
detached: true,
|
||||
stdio: 'ignore',
|
||||
shell: platform === 'win32' ? true : undefined,
|
||||
// On Windows a detached child gets its own console window; with shell:true
|
||||
// that window would flash during a passive background update. Hide it so
|
||||
// the silent updater stays silent.
|
||||
windowsHide: platform === 'win32' ? true : undefined,
|
||||
});
|
||||
child.once('error', () => { finish(false); });
|
||||
child.once('exit', (code) => { finish(code === 0); });
|
||||
|
|
|
|||
|
|
@ -600,6 +600,27 @@ describe('runUpdatePreflight', () => {
|
|||
}));
|
||||
});
|
||||
|
||||
it('win32 background auto-update hides the console window', async () => {
|
||||
mocks.readUpdateCache.mockResolvedValue(cacheWith('0.5.0'));
|
||||
mocks.readUpdateInstallState.mockResolvedValue(installState());
|
||||
mocks.refreshUpdateCache.mockResolvedValue(cacheWith('0.5.0'));
|
||||
mocks.detectInstallSource.mockResolvedValue('npm-global');
|
||||
mockSpawnExit(0);
|
||||
const originalPlatform = process.platform;
|
||||
Object.defineProperty(process, 'platform', { value: 'win32' });
|
||||
try {
|
||||
const { options } = captureOutput();
|
||||
await expect(runUpdatePreflight('0.4.0', options)).resolves.toBe('continue');
|
||||
expect(mocks.spawn).toHaveBeenCalledWith(
|
||||
'npm.cmd',
|
||||
['install', '-g', '@moonshot-ai/kimi-code@0.5.0'],
|
||||
{ detached: true, stdio: 'ignore', shell: true, windowsHide: true },
|
||||
);
|
||||
} finally {
|
||||
Object.defineProperty(process, 'platform', { value: originalPlatform });
|
||||
}
|
||||
});
|
||||
|
||||
it('tracks and logs successful background update installs', async () => {
|
||||
mocks.readUpdateCache.mockResolvedValue(cacheWith('0.5.0'));
|
||||
mocks.readUpdateInstallState.mockResolvedValue(installState());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue