You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Windows: console window is created hidden then shown ~150ms later (ACL-layer fix does not help) — 0.1.5-rc.3
#8160
On Windows, every tool call opens a visible black console window that stays
on screen for as long as the command runs. The window is created hidden — windowsHide: true works — but something makes it visible ~150 ms later.
The fix described in #1344 (ACL-sandbox STARTF_USESHOWWINDOW | SW_HIDE) does not address it: the window is owned by an ordinary node.exe whose parent is
the DSH backend, not by a restricted-token child. I was unable to identify what
shows the window.
Note: #1344 and #1564 describe rc.8. This report is 0.1.5-rc.3 — the
behaviour may or may not be the same defect.
3. Repro
Run this watcher outside the DSH sandbox (double-click the .cmd; the
session's restricted token cannot query other processes). It enumerates all
top-level windows on a poll and logs both creation and visibility changes:
Then have the agent run any command (e.g. three separate pwsh tool calls).
4. Observed evidence
Three consecutive tool calls, identical every time:
[22:57:39.586] NEW class=ConsoleWindowClass visible=False size=993x519 at 156,156
[22:57:39.587] title : 'C:\Program Files\nodejs\node.exe'
[22:57:39.588] owner=PID 26204 node started 22:57:39.535
[22:57:39.686] chain : node.exe(26204) <- node.exe(33124) (child <- parent)
[22:57:39.735] VIS hwnd=0x5D0A84 visible -> True ← 149 ms after creation
[22:57:41.580] NEW visible=False node.exe(36384) <- node.exe(33124)
[22:57:41.742] VIS visible -> True ← 162 ms
[22:57:45.178] NEW visible=False node.exe(12008) <- node.exe(33124)
[22:57:45.329] VIS visible -> True ← 150 ms
Facts established:
windowsHide: true works — the console window is created hidden
(visible=False on the NEW line).
Something shows it ~150 ms later (IsWindowVisible flips False→True).
This is not a one-off: 3/3 calls, ±10 ms.
Window size is constant 993x519; the position cascades
(130,130 → 156,156 → 182,182 → 208,208) = the Windows default cascade
for newly created console windows, i.e. one new window per tool call.
Owner is a fresh node.exe per call, whose parent is the DSH backend
(PID 33124, confirmed via netstat -ano on port 3080). powershell.exe
attaches to that console — it does not own it.
Matches the user-visible symptom: "one window per command", and the window stays for the whole duration of the command (long command → long-lived window).
5. What I ruled out
ACL sandbox layer.@deepseek-ai/dsh-win32-process builds STARTUPINFOW
with only dwFlags = 256 (STARTF_USESTDHANDLES). I patched both encodeStartupInfo call sites to dwFlags = 256 | STARTF_USESHOWWINDOW plus wShowWindow: SW_HIDE, cold-started, and the window still appears. The
captured window's owner is an ordinary node.exe, not a restricted-token child. (Patch since reverted; original bytes restored.)
No DSH code calls a showing API. Repo-wide grep over node_modules/@deepseek-ai
for ShowWindow / SW_SHOW / AllocConsole / AttachConsole / FreeConsole / SetConsoleWindowInfo: no matches (other than the literal wShowWindow
struct field name and my own experiment). So the show is not a direct API call
from DSH.
Local subprocess path already hides.dsh-subprocess-local's spawnSubprocess already passes windowsHide: platform === "win32"; its runner-launch bundle also has windowsHide: true at two more sites.
Not node-pty/ConPTY.node-pty is present but used only by spawnTerminal. A one-shot pwsh tool call does not go through it.
Early-hide from inside the pwsh child does not help. From the child I do GetConsoleWindow() + ShowWindow(SW_HIDE) (hot path 0.14 ms). Self-measured
result: 0 visibility-change events in 2 s — yet the user still sees the
window. Conclusion: the window the user sees is not the pwsh child's
console, so hiding one's own console is the wrong lever.
6. What I could not determine
What shows the window at ~150 ms. Candidates I could not distinguish:
a console-host (conhost) behaviour when a console is created for a
console-subsystem child of a console-less parent;
windowsHide being ineffective in that specific shape (parent has no console),
with the window then appearing as the console host initialises;
a second window created by a layer I could not instrument.
Both appear to target the sandbox path. This report adds that on 0.1.5-rc.3 a visible console window is created on the ordinary Node
subprocess path, is created hidden, and is shown afterwards.
8. Attachments / scripts
8.1 watcher (enumeration + visibility changes)
# Save as watch-console2.ps1 (UTF-8 WITH BOM) and run OUTSIDE the DSH sandbox.# Enumerates ALL top-level windows every 25 ms; logs NEW windows and visibility changes.$ErrorActionPreference='Continue'try { [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false) } catch { }
Add-Type-Namespace CW2 -Name Native -MemberDefinition @'public delegate bool EnumWindowsProc(System.IntPtr hWnd, System.IntPtr lParam);[DllImport("user32.dll")] public static extern bool EnumWindows(EnumWindowsProc cb, System.IntPtr lParam);[DllImport("user32.dll")] public static extern bool IsWindowVisible(System.IntPtr h);[DllImport("user32.dll", CharSet=CharSet.Unicode)] public static extern int GetClassNameW(System.IntPtr h, System.Text.StringBuilder s, int n);[DllImport("user32.dll", CharSet=CharSet.Unicode)] public static extern int GetWindowTextW(System.IntPtr h, System.Text.StringBuilder s, int n);[DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(System.IntPtr h, out uint pid);[DllImport("user32.dll")] public static extern bool GetWindowRect(System.IntPtr h, out RECT r);public struct RECT { public int L, T, R, B; }'@$logPath=Join-Path$PSScriptRoot'console-watch2.log'$interesting=@('ConsoleWindowClass','CASCADIA_HOSTING_WINDOW_CLASS')
$state=@{}; $meta=@{}
functionWrite-Log([string]$text) {
$line="[{0:HH:mm:ss.fff}] {1}"-f (Get-Date),$textAdd-Content-Path $logPath-Value $line-Encoding UTF8
Write-Host$line
}
functionGet-Chain([uint32]$owner) {
try {
$cur=$owner; $parts=@()
for ($i=0; $i-lt5; $i++) {
$ci=Get-CimInstance Win32_Process -Filter "ProcessId=$cur"-ErrorAction Stop
if (-not$ci) { break }
$parts+= ("{0}({1})"-f$ci.Name,$ci.ProcessId)
if (-not$ci.ParentProcessId-or$ci.ParentProcessId-eq0) { break }
$cur=$ci.ParentProcessId
}
if ($parts.Count-gt0) { return ($parts-join' <- ') }
} catch { return"(CIM failed: $($_.Exception.Message))" }
return'?'
}
Write-Log"=== console-watch v2 started (pid $PID) ==="while ($true) {
$found=@{}
$cb= [CW2.Native+EnumWindowsProc]{
param($hWnd,$lParam)
$cls=New-Object System.Text.StringBuilder 256
[void][CW2.Native]::GetClassNameW($hWnd,$cls,256)
$clsName=$cls.ToString()
if ($interesting-contains$clsName) {
$key=$hWnd.ToInt64(); $found[$key] =$true$vis= [CW2.Native]::IsWindowVisible($hWnd)
if (-not$state.ContainsKey($key)) {
$sb=New-Object System.Text.StringBuilder 512
[void][CW2.Native]::GetWindowTextW($hWnd,$sb,512)
$owner= [uint32]0
[void][CW2.Native]::GetWindowThreadProcessId($hWnd, [ref]$owner)
$r=New-Object CW2.Native+RECT
[void][CW2.Native]::GetWindowRect($hWnd, [ref]$r)
$state[$key] =$vis; $meta[$key] ="owner=PID $owner"Write-Log"NEW class=$clsName visible=$vis size=$($r.R-$r.L)x$($r.B-$r.T) at $($r.L),$($r.T)"Write-Log" title : '$($sb.ToString())'"Write-Log" chain : $(Get-Chain$owner) (child <- parent)"
} elseif ($state[$key] -ne$vis) {
$state[$key] =$visWrite-Log"VIS hwnd=0x$($key.ToString('X')) visible -> $vis$($meta[$key])"
}
}
return$true
}
[void][CW2.Native]::EnumWindows($cb, [IntPtr]::Zero)
foreach ($kin@($state.Keys)) { if (-not$found.ContainsKey($k)) { $state.Remove($k); $meta.Remove($k) } }
Start-Sleep-Milliseconds 25
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
1. Summary
On Windows, every tool call opens a visible black console window that stays
on screen for as long as the command runs. The window is created hidden —
windowsHide: trueworks — but something makes it visible ~150 ms later.The fix described in #1344 (ACL-sandbox
STARTF_USESHOWWINDOW | SW_HIDE) doesnot address it: the window is owned by an ordinary
node.exewhose parent isthe DSH backend, not by a restricted-token child. I was unable to identify what
shows the window.
2. Environment
0.1.5-rc.3(npx install:%LOCALAPPDATA%\npm-cache\_npx\1e7f6d9597241db0)dsh web, detached server)10.0.19044v24.21.0C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe) —pwsh7 is not installed on this machineworkspace-writeHKCU\Console→ForceV2 = 1;HKCU\Console\%%Startupabsent;MinAnimate = 13. Repro
Run this watcher outside the DSH sandbox (double-click the
.cmd; thesession's restricted token cannot query other processes). It enumerates all
top-level windows on a poll and logs both creation and visibility changes:
tools\watch-console2.cmd/tools\watch-console2.ps1(script appended below)console-watch2.logThen have the agent run any command (e.g. three separate
pwshtool calls).4. Observed evidence
Three consecutive tool calls, identical every time:
Facts established:
windowsHide: trueworks — the console window is created hidden(
visible=Falseon theNEWline).IsWindowVisibleflips False→True).This is not a one-off: 3/3 calls, ±10 ms.
993x519; the position cascades(
130,130→156,156→182,182→208,208) = the Windows default cascadefor newly created console windows, i.e. one new window per tool call.
node.exeper call, whose parent is the DSH backend(
PID 33124, confirmed vianetstat -anoon port 3080).powershell.exeattaches to that console — it does not own it.
stays for the whole duration of the command (long command → long-lived window).
5. What I ruled out
@deepseek-ai/dsh-win32-processbuildsSTARTUPINFOWwith only
dwFlags = 256(STARTF_USESTDHANDLES). I patched bothencodeStartupInfocall sites todwFlags = 256 | STARTF_USESHOWWINDOWpluswShowWindow: SW_HIDE, cold-started, and the window still appears. Thecaptured window's owner is an ordinary
node.exe, not a restricted-token child.(Patch since reverted; original bytes restored.)
node_modules/@deepseek-aifor
ShowWindow/SW_SHOW/AllocConsole/AttachConsole/FreeConsole/SetConsoleWindowInfo: no matches (other than the literalwShowWindowstruct field name and my own experiment). So the show is not a direct API call
from DSH.
dsh-subprocess-local'sspawnSubprocessalready passeswindowsHide: platform === "win32"; itsrunner-launchbundle also haswindowsHide: trueat two more sites.node-pty/ConPTY.node-ptyis present but used only byspawnTerminal. A one-shotpwshtool call does not go through it.GetConsoleWindow()+ShowWindow(SW_HIDE)(hot path 0.14 ms). Self-measuredresult: 0 visibility-change events in 2 s — yet the user still sees the
window. Conclusion: the window the user sees is not the pwsh child's
console, so hiding one's own console is the wrong lever.
6. What I could not determine
What shows the window at ~150 ms. Candidates I could not distinguish:
conhost) behaviour when a console is created for aconsole-subsystem child of a console-less parent;
windowsHidebeing ineffective in that specific shape (parent has no console),with the window then appearing as the console host initialises;
7. Related
[Bug][Windows] Sandboxed subprocess spawn flashes a visible console window from GUI hosts; STARTF_USESHOWWINDOW + SW_HIDE fixes it without the 0xC0000142 crashdsh-no-console-flashcommunity patchBoth appear to target the sandbox path. This report adds that on
0.1.5-rc.3 a visible console window is created on the ordinary Node
subprocess path, is created hidden, and is shown afterwards.
8. Attachments / scripts
8.1 watcher (enumeration + visibility changes)
8.2 in-child console self-inspection (one PowerShell command)
Observed on 0.1.5-rc.3:
title = 'C:\Program Files\nodejs\node.exe',owner= a freshnode.exe(notpowershell.exe),IsWindowVisible = True.All reactions