From c7c45053977b7eab8854af73d51b0966d565901a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=93=E8=89=AF?= <1204183885@qq.com> Date: Thu, 13 Aug 2026 07:20:21 +0000 Subject: [PATCH 1/5] fix(desktop): hide the Windows runtime terminal and align reduced-motion startup On Windows the bundled runtime (node.exe, a console application) was spawned without CREATE_NO_WINDOW, so the desktop (a GUI application) allocated a visible terminal window for it; closing that window stopped the runtime with exit code 1 (#9043). Route the spawn through a platform-specific helper that sets CREATE_NO_WINDOW via the command-group builder (group_spawn would overwrite creation flags set directly on the command). Add a Windows-only regression test that asserts the spawned child receives no console window. The reduced-motion bootstrap fallback showed the logo left-aligned inside the shell while the newly visible status text was centered in a wider card, so the two did not share a horizontal center. Stack and center both inside the shell and drop the leftover card chrome, mirroring the simplified startup view from #8988, and extend the bootstrap release check to guard the centering rules. --- packages/desktop-shell/bootstrap/index.html | 9 +++ .../desktop-shell/scripts/test-release.js | 5 ++ .../desktop-shell/src-tauri/src/runtime.rs | 56 ++++++++++++++++++- 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/packages/desktop-shell/bootstrap/index.html b/packages/desktop-shell/bootstrap/index.html index f7a1de00777..bb6ac8f3e0b 100644 --- a/packages/desktop-shell/bootstrap/index.html +++ b/packages/desktop-shell/bootstrap/index.html @@ -127,12 +127,21 @@ body[data-state='starting'] .mark { animation: none; } + /* The visible status text stacks under the logo; center both so they + share the same horizontal center as the animated logo-only view. */ + body[data-state='starting'] .shell { + display: flex; + flex-direction: column; + align-items: center; + } body[data-state='starting'] .status { position: static; width: auto; height: auto; margin: 18px 0 0; + padding: 0; overflow: visible; + border: 0; clip: auto; clip-path: none; white-space: normal; diff --git a/packages/desktop-shell/scripts/test-release.js b/packages/desktop-shell/scripts/test-release.js index 15a26b60419..fd873babb60 100755 --- a/packages/desktop-shell/scripts/test-release.js +++ b/packages/desktop-shell/scripts/test-release.js @@ -68,6 +68,11 @@ async function testBootstrapWorkspaceVisibility() { 'The bootstrap splash mark must ship with the frontendDist directory.', ); assert.doesNotMatch(bootstrapHtml, /class="mark">Q std::io::Result { + const CREATE_NO_WINDOW: u32 = 0x08000000; + command.group().creation_flags(CREATE_NO_WINDOW).spawn() +} + +#[cfg(not(windows))] +fn spawn_runtime_group(command: &mut Command) -> std::io::Result { + command.group_spawn() +} + struct RuntimeLayout { node: PathBuf, entry: PathBuf, @@ -543,7 +559,7 @@ mod tests { #[cfg(unix)] use super::{stop_runtime_handle, wait_for_listening}; #[cfg(windows)] - use super::layout_from_root; + use super::{layout_from_root, spawn_runtime_group}; use std::path::Path; #[cfg(windows)] use std::path::PathBuf; @@ -598,6 +614,40 @@ mod tests { assert!(error.contains("unsupported Windows extended-length form")); } + // The bundled runtime is a console application, so it must be created + // with `CREATE_NO_WINDOW`: the probe child reports its own attached + // console window, and there must be none (#9043). + #[cfg(windows)] + #[test] + fn runtime_child_gets_no_windows_console() { + let probe = concat!( + "Add-Type -Namespace QwenDesktop -Name ConsoleProbe", + " -MemberDefinition '[DllImport(\"kernel32.dll\")]", + " public static extern IntPtr GetConsoleWindow();';", + " [QwenDesktop.ConsoleProbe]::GetConsoleWindow().ToInt64()", + ); + let mut command = std::process::Command::new("powershell.exe"); + command + .args(["-NoProfile", "-NonInteractive", "-Command", probe]) + .stdin(std::process::Stdio::null()) + .stdout(std::process::Stdio::piped()) + .stderr(std::process::Stdio::piped()); + let output = spawn_runtime_group(&mut command) + .expect("spawn hidden runtime child") + .wait_with_output() + .expect("collect hidden runtime child output"); + assert!( + output.status.success(), + "console probe child failed: {}", + String::from_utf8_lossy(&output.stderr) + ); + assert_eq!( + String::from_utf8_lossy(&output.stdout).trim(), + "0", + "the runtime child must not receive a console window" + ); + } + #[cfg(windows)] #[test] fn runtime_layout_strips_windows_verbatim_prefix() { From 1073c07f0640326b103ebf1f245f6d5121eecd34 Mon Sep 17 00:00:00 2001 From: yiliang114 Date: Thu, 13 Aug 2026 17:09:38 +0800 Subject: [PATCH 2/5] fix(desktop): simplify reduced-motion startup centering --- packages/desktop-shell/bootstrap/index.html | 10 ++-------- packages/desktop-shell/scripts/test-release.js | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/packages/desktop-shell/bootstrap/index.html b/packages/desktop-shell/bootstrap/index.html index bb6ac8f3e0b..948f796ca41 100644 --- a/packages/desktop-shell/bootstrap/index.html +++ b/packages/desktop-shell/bootstrap/index.html @@ -127,21 +127,15 @@ body[data-state='starting'] .mark { animation: none; } - /* The visible status text stacks under the logo; center both so they - share the same horizontal center as the animated logo-only view. */ - body[data-state='starting'] .shell { - display: flex; - flex-direction: column; - align-items: center; + body[data-state='starting'] .brand { + justify-content: center; } body[data-state='starting'] .status { position: static; width: auto; height: auto; margin: 18px 0 0; - padding: 0; overflow: visible; - border: 0; clip: auto; clip-path: none; white-space: normal; diff --git a/packages/desktop-shell/scripts/test-release.js b/packages/desktop-shell/scripts/test-release.js index fd873babb60..265dd997f99 100755 --- a/packages/desktop-shell/scripts/test-release.js +++ b/packages/desktop-shell/scripts/test-release.js @@ -70,7 +70,7 @@ async function testBootstrapWorkspaceVisibility() { assert.doesNotMatch(bootstrapHtml, /class="mark">Q Date: Thu, 13 Aug 2026 22:14:35 +0800 Subject: [PATCH 3/5] fix(core): hide daemon-side console spawns on Windows With the bundled runtime spawned console-less, console-app children of the daemon no longer inherit a console and each allocates a visible window. Pass windowsHide at the git attribution, git notes, and taskkill spawn sites in the shell tool, matching shellExecutionService. Also loosen the reduced-motion bootstrap assertion so it no longer hard-codes rule order inside the media block. --- packages/core/src/tools/shell.ts | 34 +++++++++++-------- .../desktop-shell/scripts/test-release.js | 20 ++++++++--- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/packages/core/src/tools/shell.ts b/packages/core/src/tools/shell.ts index b3c368d63f7..43537ce1eac 100644 --- a/packages/core/src/tools/shell.ts +++ b/packages/core/src/tools/shell.ts @@ -3099,12 +3099,13 @@ export class ShellToolInvocation extends BaseToolInvocation< if (pid !== undefined) { if (os.platform() === 'win32') { try { - const taskkillChild = childProcess.spawn('taskkill', [ - '/pid', - String(pid), - '/f', - '/t', - ]); + const taskkillChild = childProcess.spawn( + 'taskkill', + ['/pid', String(pid), '/f', '/t'], + // The desktop runtime daemon has no console; without this + // flag each console-app child allocates a visible window. + { windowsHide: true }, + ); taskkillChild.on('error', () => { /* swallow — already in error path */ }); @@ -3249,12 +3250,13 @@ export class ShellToolInvocation extends BaseToolInvocation< if (pid !== undefined) { if (os.platform() === 'win32') { try { - const taskkillChild = childProcess.spawn('taskkill', [ - '/pid', - String(pid), - '/f', - '/t', - ]); + const taskkillChild = childProcess.spawn( + 'taskkill', + ['/pid', String(pid), '/f', '/t'], + // The desktop runtime daemon has no console; without this + // flag each console-app child allocates a visible window. + { windowsHide: true }, + ); // Without an 'error' listener on the spawned ChildProcess, // a taskkill spawn failure (binary missing, permission // denied, etc.) would emit 'error' with no listener — which @@ -3812,7 +3814,7 @@ export class ShellToolInvocation extends BaseToolInvocation< const child = childProcess.execFile( 'git', args, - { cwd, timeout: 2000 }, + { cwd, timeout: 2000, windowsHide: true }, (error, stdout) => { if (error) { resolve(0); @@ -3840,7 +3842,7 @@ export class ShellToolInvocation extends BaseToolInvocation< const child = childProcess.execFile( 'git', ['rev-parse', 'HEAD'], - { cwd, timeout: 2000 }, + { cwd, timeout: 2000, windowsHide: true }, (error, stdout) => { if (error) { resolve(null); @@ -3874,6 +3876,7 @@ export class ShellToolInvocation extends BaseToolInvocation< const stdout = childProcess.execFileSync('git', ['rev-parse', 'HEAD'], { cwd, timeout: 2000, + windowsHide: true, // Discard stderr noise (e.g. "fatal: not a git repository") — // the catch-or-empty-output path already covers failure. stdio: ['ignore', 'pipe', 'ignore'], @@ -4108,6 +4111,7 @@ export class ShellToolInvocation extends BaseToolInvocation< .execFileSync('git', ['show', `${postHead}:${rel}`], { cwd, timeout: 2000, + windowsHide: true, stdio: ['ignore', 'pipe', 'ignore'], maxBuffer: 16 * 1024 * 1024, }) @@ -4193,7 +4197,7 @@ export class ShellToolInvocation extends BaseToolInvocation< const child = childProcess.execFile( notesCommand.command, notesCommand.args, - { cwd, timeout: 5000 }, + { cwd, timeout: 5000, windowsHide: true }, (error, stdout, stderr) => { const merged = (stdout || '') + (stderr || ''); if (error) { diff --git a/packages/desktop-shell/scripts/test-release.js b/packages/desktop-shell/scripts/test-release.js index 265dd997f99..4dc12be77e2 100755 --- a/packages/desktop-shell/scripts/test-release.js +++ b/packages/desktop-shell/scripts/test-release.js @@ -68,11 +68,23 @@ async function testBootstrapWorkspaceVisibility() { 'The bootstrap splash mark must ship with the frontendDist directory.', ); assert.doesNotMatch(bootstrapHtml, /class="mark">Q)/, + ); + assert.ok( + reducedMotionBlock, + 'The bootstrap splash must keep a reduced-motion media block.', ); + for (const centeringRule of [ + /body\[data-state='starting'\] \.brand \{[^}]*justify-content: center;[^}]*\}/, + /body\[data-state='starting'\] \.status \{[^}]*text-align: center;[^}]*\}/, + ]) { + assert.match( + reducedMotionBlock[1], + centeringRule, + 'The reduced-motion startup view must keep the logo and status text on the same horizontal center.', + ); + } const primary = await createBootstrapHarness(); const { body, commands, element, listeners, resolveBootstrapState } = primary; From 9ef0043ba3e1e27cdad7ef903959b869dfa77c7c Mon Sep 17 00:00:00 2001 From: yiliang114 Date: Thu, 13 Aug 2026 22:30:12 +0800 Subject: [PATCH 4/5] fix(desktop): hide runtime descendant consoles --- packages/acp-bridge/src/spawnChannel.test.ts | 3 +- packages/acp-bridge/src/spawnChannel.ts | 1 + .../services/shellExecutionService.test.ts | 159 +++++++++--------- .../src/services/shellExecutionService.ts | 33 ++-- .../src-tauri/src/local_control.rs | 14 +- 5 files changed, 110 insertions(+), 100 deletions(-) diff --git a/packages/acp-bridge/src/spawnChannel.test.ts b/packages/acp-bridge/src/spawnChannel.test.ts index 2b333644434..ca3fc3686df 100644 --- a/packages/acp-bridge/src/spawnChannel.test.ts +++ b/packages/acp-bridge/src/spawnChannel.test.ts @@ -131,8 +131,9 @@ describe('createSpawnChannelFactory env policy', () => { }); const spawnOptions = mockSpawn.mock.calls[0]?.[2] as - | { env?: NodeJS.ProcessEnv } + | { env?: NodeJS.ProcessEnv; windowsHide?: boolean } | undefined; + expect(spawnOptions?.windowsHide).toBe(true); expect(spawnOptions?.env).not.toHaveProperty('QWEN_CODE_SIMPLE'); expect(spawnOptions?.env).not.toHaveProperty('QWEN_SERVER_TOKEN'); expect(spawnOptions?.env).not.toHaveProperty( diff --git a/packages/acp-bridge/src/spawnChannel.ts b/packages/acp-bridge/src/spawnChannel.ts index 72970435340..9dffacdfda6 100644 --- a/packages/acp-bridge/src/spawnChannel.ts +++ b/packages/acp-bridge/src/spawnChannel.ts @@ -474,6 +474,7 @@ export function createSpawnChannelFactory( { cwd: workspaceCwd, stdio: ['pipe', 'pipe', 'pipe'], + windowsHide: true, env: childEnv, }, ); diff --git a/packages/core/src/services/shellExecutionService.test.ts b/packages/core/src/services/shellExecutionService.test.ts index fbf1ea62ff9..26caef85f7a 100644 --- a/packages/core/src/services/shellExecutionService.test.ts +++ b/packages/core/src/services/shellExecutionService.test.ts @@ -127,6 +127,7 @@ const mockProcessKill = vi // to avoid PATH/CWD binary planting. Compute the expected path the same way so // assertions stay in sync across platforms (SystemRoot is unset off Windows). const TASKKILL = `${process.env['SystemRoot'] || 'C:\\Windows'}\\System32\\taskkill.exe`; +const HIDDEN_WINDOW = { windowsHide: true }; const CHCP = `${process.env['SystemRoot'] || 'C:\\Windows'}\\System32\\chcp.com`; const shellExecutionConfig = { @@ -1411,29 +1412,27 @@ describe('ShellExecutionService', () => { expect(result.aborted).toBe(true); // Cancel tree-kills (/t) SYNCHRONOUSLY (spawnSync) so taskkill enumerates // the tree before ptyProcess.kill() fires ClosePseudoConsole. See #5873. - expect(mockSpawnSync).toHaveBeenCalledWith(TASKKILL, [ - '/f', - '/t', - '/pid', - String(mockPtyProcess.pid), - ]); + expect(mockSpawnSync).toHaveBeenCalledWith( + TASKKILL, + ['/f', '/t', '/pid', String(mockPtyProcess.pid)], + HIDDEN_WINDOW, + ); // The finalizer reap (async cpSpawn via windowsKillPid) must ALSO // tree-kill on cancel — positively asserted so removing the reap or // forcing cancelKillDispatched=false fails here, not just trivially via // the negative check below. See #5873. - expect(mockCpSpawn).toHaveBeenCalledWith(TASKKILL, [ - '/f', - '/t', - '/pid', - String(mockPtyProcess.pid), - ]); + expect(mockCpSpawn).toHaveBeenCalledWith( + TASKKILL, + ['/f', '/t', '/pid', String(mockPtyProcess.pid)], + HIDDEN_WINDOW, + ); // ...and it must never downgrade to a shell-only (/f without /t) kill // that could leave the abandoned descendant tree behind. See #5873. - expect(mockCpSpawn).not.toHaveBeenCalledWith(TASKKILL, [ - '/f', - '/pid', - String(mockPtyProcess.pid), - ]); + expect(mockCpSpawn).not.toHaveBeenCalledWith( + TASKKILL, + ['/f', '/pid', String(mockPtyProcess.pid)], + HIDDEN_WINDOW, + ); // ...and still calls ptyProcess.kill() so that if taskkill cannot launch, // the ConPTY host is torn down and onExit fires (the cancel can't hang). // See #5873. @@ -1457,17 +1456,16 @@ describe('ShellExecutionService', () => { expect(result.exitCode).toBe(0); // Reap kills only the shell pid — no /t — so a child the command // intentionally detached (e.g. Start-Process) survives. See #5873. - expect(mockCpSpawn).toHaveBeenCalledWith(TASKKILL, [ - '/f', - '/pid', - String(mockPtyProcess.pid), - ]); - expect(mockCpSpawn).not.toHaveBeenCalledWith(TASKKILL, [ - '/f', - '/t', - '/pid', - String(mockPtyProcess.pid), - ]); + expect(mockCpSpawn).toHaveBeenCalledWith( + TASKKILL, + ['/f', '/pid', String(mockPtyProcess.pid)], + HIDDEN_WINDOW, + ); + expect(mockCpSpawn).not.toHaveBeenCalledWith( + TASKKILL, + ['/f', '/t', '/pid', String(mockPtyProcess.pid)], + HIDDEN_WINDOW, + ); }); it('normal completion on win32 swallows a taskkill launch error (no crash)', async () => { @@ -1514,6 +1512,7 @@ describe('ShellExecutionService', () => { expect(mockCpSpawn).not.toHaveBeenCalledWith( TASKKILL, expect.anything(), + HIDDEN_WINDOW, ); } finally { // clearAllMocks() resets calls but not implementations — restore the @@ -1529,7 +1528,11 @@ describe('ShellExecutionService', () => { }); expect(result.exitCode).toBe(0); - expect(mockCpSpawn).not.toHaveBeenCalledWith(TASKKILL, expect.anything()); + expect(mockCpSpawn).not.toHaveBeenCalledWith( + TASKKILL, + expect.anything(), + HIDDEN_WINDOW, + ); }); it('exit cleanup on win32 tree-kills via taskkill and tears down the host', () => { @@ -1546,12 +1549,11 @@ describe('ShellExecutionService', () => { ShellExecutionService.cleanup(); ShellExecutionService['activePtys'].delete(pid); - expect(mockSpawnSync).toHaveBeenCalledWith(TASKKILL, [ - '/f', - '/t', - '/pid', - String(pid), - ]); + expect(mockSpawnSync).toHaveBeenCalledWith( + TASKKILL, + ['/f', '/t', '/pid', String(pid)], + HIDDEN_WINDOW, + ); // The ConPTY host is torn down unconditionally, alongside the tree-kill. expect(mockPtyProcess.kill).toHaveBeenCalled(); }); @@ -1622,17 +1624,17 @@ describe('ShellExecutionService', () => { expect(result.aborted).toBe(true); // performCancelKill's sync tree-kill still runs... - expect(mockSpawnSync).toHaveBeenCalledWith(TASKKILL, [ - '/f', - '/t', - '/pid', - String(mockPtyProcess.pid), - ]); + expect(mockSpawnSync).toHaveBeenCalledWith( + TASKKILL, + ['/f', '/t', '/pid', String(mockPtyProcess.pid)], + HIDDEN_WINDOW, + ); // ...but the finalizer reap is skipped (isPtyActive false via ESRCH), // so no async taskkill fires there. expect(mockCpSpawn).not.toHaveBeenCalledWith( TASKKILL, expect.anything(), + HIDDEN_WINDOW, ); } finally { mockProcessKill.mockImplementation(() => true); @@ -1670,12 +1672,11 @@ describe('ShellExecutionService', () => { // Pins killChildProcesses on the absolute System32 path — a regression to // the bare 'taskkill' name reopens the binary-planting hole. See #5873. - expect(mockSpawnSync).toHaveBeenCalledWith(TASKKILL, [ - '/f', - '/t', - '/pid', - String(childPid), - ]); + expect(mockSpawnSync).toHaveBeenCalledWith( + TASKKILL, + ['/f', '/t', '/pid', String(childPid)], + HIDDEN_WINDOW, + ); }); it('win32 taskkill is invoked by absolute System32 path, not the bare name', async () => { @@ -1713,17 +1714,16 @@ describe('ShellExecutionService', () => { ); expect(result.exitCode).toBe(0); - expect(mockCpSpawn).toHaveBeenCalledWith(TASKKILL, [ - '/f', - '/pid', - String(mockPtyProcess.pid), - ]); - expect(mockCpSpawn).not.toHaveBeenCalledWith(TASKKILL, [ - '/f', - '/t', - '/pid', - String(mockPtyProcess.pid), - ]); + expect(mockCpSpawn).toHaveBeenCalledWith( + TASKKILL, + ['/f', '/pid', String(mockPtyProcess.pid)], + HIDDEN_WINDOW, + ); + expect(mockCpSpawn).not.toHaveBeenCalledWith( + TASKKILL, + ['/f', '/t', '/pid', String(mockPtyProcess.pid)], + HIDDEN_WINDOW, + ); }); it('win32 promoted shell reaps its lingering pwsh on natural exit (shell-pid-only)', async () => { @@ -1754,17 +1754,16 @@ describe('ShellExecutionService', () => { postPromoteExitHandler({ exitCode: 0, signal: undefined }); expect(settleCalls).toHaveLength(1); - expect(mockCpSpawn).toHaveBeenCalledWith(TASKKILL, [ - '/f', - '/pid', - String(mockPtyProcess.pid), - ]); - expect(mockCpSpawn).not.toHaveBeenCalledWith(TASKKILL, [ - '/f', - '/t', - '/pid', - String(mockPtyProcess.pid), - ]); + expect(mockCpSpawn).toHaveBeenCalledWith( + TASKKILL, + ['/f', '/pid', String(mockPtyProcess.pid)], + HIDDEN_WINDOW, + ); + expect(mockCpSpawn).not.toHaveBeenCalledWith( + TASKKILL, + ['/f', '/t', '/pid', String(mockPtyProcess.pid)], + HIDDEN_WINDOW, + ); }); it('win32 promoted shell reaps on natural exit even with onData only (no onSettle)', async () => { @@ -1790,11 +1789,11 @@ describe('ShellExecutionService', () => { onExitRegistrations[onExitRegistrations.length - 1][0]; postPromoteExitHandler({ exitCode: 0, signal: undefined }); - expect(mockCpSpawn).toHaveBeenCalledWith(TASKKILL, [ - '/f', - '/pid', - String(mockPtyProcess.pid), - ]); + expect(mockCpSpawn).toHaveBeenCalledWith( + TASKKILL, + ['/f', '/pid', String(mockPtyProcess.pid)], + HIDDEN_WINDOW, + ); }); it('win32 promoted shell skips the post-settle reap when the pty already exited', async () => { @@ -1834,6 +1833,7 @@ describe('ShellExecutionService', () => { expect(mockCpSpawn).not.toHaveBeenCalledWith( TASKKILL, expect.anything(), + HIDDEN_WINDOW, ); } finally { mockProcessKill.mockImplementation(() => true); @@ -2632,12 +2632,11 @@ describe('ShellExecutionService child_process fallback', () => { expectedSignal, ); } else { - expect(mockCpSpawn).toHaveBeenCalledWith(expectedCommand, [ - '/f', - '/t', - '/pid', - String(mockChildProcess.pid), - ]); + expect(mockCpSpawn).toHaveBeenCalledWith( + expectedCommand, + ['/f', '/t', '/pid', String(mockChildProcess.pid)], + HIDDEN_WINDOW, + ); } }); }, diff --git a/packages/core/src/services/shellExecutionService.ts b/packages/core/src/services/shellExecutionService.ts index 839dd66744a..da7a84fb362 100644 --- a/packages/core/src/services/shellExecutionService.ts +++ b/packages/core/src/services/shellExecutionService.ts @@ -550,6 +550,7 @@ interface ProcessCleanupStrategy { // workspace or on PATH could run from these cleanup paths with the CLI's // environment — arbitrary code execution out of a benign teardown. See #5873. const WINDOWS_TASKKILL = `${process.env['SystemRoot'] || 'C:\\Windows'}\\System32\\taskkill.exe`; +const WINDOWS_TASKKILL_OPTIONS = { windowsHide: true } as const; const windowsKillPid = (pid: number, tree: boolean): void => { try { @@ -558,7 +559,7 @@ const windowsKillPid = (pid: number, tree: boolean): void => { const args = tree ? ['/f', '/t', '/pid', pid.toString()] : ['/f', '/pid', pid.toString()]; - const killer = cpSpawn(WINDOWS_TASKKILL, args); + const killer = cpSpawn(WINDOWS_TASKKILL, args, WINDOWS_TASKKILL_OPTIONS); // Log (don't crash on) a failed launch: silently swallowing it would let // the #5873 pwsh leak quietly return with no diagnostic trail under // enterprise lockdown / EMFILE / antivirus interception. @@ -597,7 +598,11 @@ const windowsStrategy: ProcessCleanupStrategy = { // before the process dies (and a sync stderr write would be exit-time // noise). The unconditional ptyProcess.kill() below is the mitigation; // the runtime reap paths (windowsKillPid), which DO flush, keep logging. - spawnSync(WINDOWS_TASKKILL, ['/f', '/t', '/pid', pid.toString()]); + spawnSync( + WINDOWS_TASKKILL, + ['/f', '/t', '/pid', pid.toString()], + WINDOWS_TASKKILL_OPTIONS, + ); } catch { // ignore } @@ -621,7 +626,7 @@ const windowsStrategy: ProcessCleanupStrategy = { } // No logging — like killPty, this runs only from the 'exit' handler // where an async debug write can't flush before the process dies. - spawnSync(WINDOWS_TASKKILL, args); + spawnSync(WINDOWS_TASKKILL, args, WINDOWS_TASKKILL_OPTIONS); } catch { // ignore } @@ -1332,12 +1337,11 @@ export class ShellExecutionService { const performCancelKill = async (): Promise => { if (!child.pid || exited) return; if (isWindows) { - const killer = cpSpawn(WINDOWS_TASKKILL, [ - '/f', - '/t', - '/pid', - child.pid.toString(), - ]); + const killer = cpSpawn( + WINDOWS_TASKKILL, + ['/f', '/t', '/pid', child.pid.toString()], + WINDOWS_TASKKILL_OPTIONS, + ); // taskkill can fail two ways, and either would otherwise hang the // cancel (the abort waits for a child exit that never comes), so // fall back to killing the child directly in both: @@ -2312,12 +2316,11 @@ export class ShellExecutionService { // cancel path). ptyProcess.kill() alone doesn't tree-kill under // ConPTY (microsoft/node-pty#333). try { - const r = spawnSync(WINDOWS_TASKKILL, [ - '/f', - '/t', - '/pid', - ptyProcess.pid.toString(), - ]); + const r = spawnSync( + WINDOWS_TASKKILL, + ['/f', '/t', '/pid', ptyProcess.pid.toString()], + WINDOWS_TASKKILL_OPTIONS, + ); if (r.error || (typeof r.status === 'number' && r.status !== 0)) { debugLogger.warn( `performCancelKill: taskkill failed for pid ${ptyProcess.pid}: ${r.error?.message ?? `exit ${r.status}`}`, diff --git a/packages/desktop-shell/src-tauri/src/local_control.rs b/packages/desktop-shell/src-tauri/src/local_control.rs index cb62b2ee29e..79d4c9427c3 100644 --- a/packages/desktop-shell/src-tauri/src/local_control.rs +++ b/packages/desktop-shell/src-tauri/src/local_control.rs @@ -633,13 +633,19 @@ fn start_sleep_inhibitor() -> Option { #[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))] return None; - Command::new(command.0) + let mut child_command = Command::new(command.0); + child_command .args(command.1) .stdin(Stdio::null()) .stdout(Stdio::null()) - .stderr(Stdio::null()) - .spawn() - .ok() + .stderr(Stdio::null()); + #[cfg(target_os = "windows")] + { + use std::os::windows::process::CommandExt; + const CREATE_NO_WINDOW: u32 = 0x08000000; + child_command.creation_flags(CREATE_NO_WINDOW); + } + child_command.spawn().ok() } fn lock(mutex: &Mutex) -> std::sync::MutexGuard<'_, T> { From 58a6acd06c652545c1cfd11b7399d567fd0996ca Mon Sep 17 00:00:00 2001 From: yiliang114 Date: Thu, 13 Aug 2026 22:54:55 +0800 Subject: [PATCH 5/5] test(desktop): pin the hidden-console spawn helper at the production call site The Rust test exercises spawn_runtime_group directly; nothing guarded that DesktopRuntime::start still routes through it. Assert the call site in the release gate so a refactor reverting to group_spawn() fails the suite. --- packages/desktop-shell/scripts/test-release.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/desktop-shell/scripts/test-release.js b/packages/desktop-shell/scripts/test-release.js index 4dc12be77e2..e567a9d3f10 100755 --- a/packages/desktop-shell/scripts/test-release.js +++ b/packages/desktop-shell/scripts/test-release.js @@ -85,6 +85,15 @@ async function testBootstrapWorkspaceVisibility() { 'The reduced-motion startup view must keep the logo and status text on the same horizontal center.', ); } + const runtimeSource = fs.readFileSync( + path.join(packageDir, 'src-tauri', 'src', 'runtime.rs'), + 'utf8', + ); + assert.match( + runtimeSource, + /let mut child = spawn_runtime_group\(&mut command\)/, + 'DesktopRuntime::start must spawn the runtime through the hidden-console helper.', + ); const primary = await createBootstrapHarness(); const { body, commands, element, listeners, resolveBootstrapState } = primary;