Repository navigation
fix(daemon): preload the windowsHide shim via --require (rc.6 shim was inert) - #7499
Conversation
The rc.6 shim shipped broken twice over: 1. Bundler ordering: rollup's CJS output hoists chunk requires above inlined module code, so daemon-entry's "first import" of the shim ran AFTER sibling chunks evaluated `promisify(childProcess.execFile)` at module scope. The shim is now its own self-contained bundle entry and the daemon fork preloads it with `node --require`, which runs before the module graph loads - immune to bundler ordering by construction. 2. promisify bypass: exec/execFile carry a util.promisify.custom implementation that calls the ORIGINAL function internally; copying the symbol verbatim onto the wrapper let every promisified call site (exactly what the daemon's CIM probes use) skip the injection. The wrapper now wraps each symbol-attached function with the same windowsHide-default injection. Verified on Windows against the staged production Node 24 binary with canary-titled probes (attributable amid ambient rc.6 flashing): plain execFile and promisify(execFile) both flash 100% of trials without the preload and 0% with it; promisify(execFile) under the preload resolves to the injection wrapper; built preload bundle has zero chunk requires; daemon boots and serves getForegroundProcess RPCs end-to-end under --require.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughChangesThis change alters how the Windows "hidden console children" shim is applied to the daemon process. The shim's wrapper logic is refactored into an exported Sequence Diagram(s)See diagrams within the hidden review stack artifact above. Related PRs: None specified. Suggested labels: bug, windows, daemon Suggested reviewers: None specified. Poem: ✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
CI test-merges main, which carries the windows-hidden-console-children test from #7499 (admin-merged with a failing verify). promisify(wrapped) resolved to its zero-arg overload; cast to the promisify.custom signature so tsgo accepts the two-arg call. Co-authored-by: Orca <[email protected]>
The windows-hidden-console-children test (from #7499, admin-merged with a failing verify) failed tsgo: promisify(wrapped) resolved to its zero-arg overload because the wrapper erased its argument to a bare variadic function and the fake never statically carried promisify.custom. Preserve the wrapped type via a generic overload (accurate: the wrapper copies the call signature and symbols verbatim) and build the fake as a real CustomPromisify, so promisify routes through the custom overload as it does in production. Co-authored-by: Orca <[email protected]>
) (#7505) * Revert "Preload the daemon windowsHide shim via --require; wrap promisify custom (#7499)" This reverts commit 8f396ba. * Revert "Hide console windows for children of the node.exe-hosted daemon (#7486)" This reverts commit f0fdd3a. * Revert "fix(daemon): relocate daemon host image out of the install-dir kill zone (#7473)" This reverts commit f4faafa. * Revert "fix(pty): keep runtime dirs a surviving daemon still uses (#7463)" This reverts commit 3cd23a1. * Revert "Relocate node-pty ConPTY runtime outside the Windows install dir (fixes update-time terminal loss) (#7421)" This reverts commit 509c41e.
* Show all worktrees across all hosts on mobile Avoid honoring desktop's host-filtering settings since mobile lacks the UI to manage or unhide them. This prevents worktrees from being silently hidden under certain host scopes. Additionally, this removes worktree filtering based on repo metadata, which previously caused worktrees to vanish when same-named repos on different hosts collapsed to a single ID. * fix(daemon): preserve promisify.custom type through wrapChildProcessApi The windows-hidden-console-children test (from #7499, admin-merged with a failing verify) failed tsgo: promisify(wrapped) resolved to its zero-arg overload because the wrapper erased its argument to a bare variadic function and the fake never statically carried promisify.custom. Preserve the wrapped type via a generic overload (accurate: the wrapper copies the call signature and symbols verbatim) and build the fake as a real CustomPromisify, so promisify routes through the custom overload as it does in production. Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Orca <[email protected]>
Records why the #7421->#7499 chain was reverted in #7505 (failure mechanisms, why verification missed them, non-negotiables), and lays out the from-scratch plan: proof harness first, relocate the daemon file closure out of the install dir while keeping the exact Electron runtime, fix adoption interactivity, and gate every phase on a packaged-artifact update test.
…tom (stablyai#7499) The rc.6 shim shipped broken twice over: 1. Bundler ordering: rollup's CJS output hoists chunk requires above inlined module code, so daemon-entry's "first import" of the shim ran AFTER sibling chunks evaluated `promisify(childProcess.execFile)` at module scope. The shim is now its own self-contained bundle entry and the daemon fork preloads it with `node --require`, which runs before the module graph loads - immune to bundler ordering by construction. 2. promisify bypass: exec/execFile carry a util.promisify.custom implementation that calls the ORIGINAL function internally; copying the symbol verbatim onto the wrapper let every promisified call site (exactly what the daemon's CIM probes use) skip the injection. The wrapper now wraps each symbol-attached function with the same windowsHide-default injection. Verified on Windows against the staged production Node 24 binary with canary-titled probes (attributable amid ambient rc.6 flashing): plain execFile and promisify(execFile) both flash 100% of trials without the preload and 0% with it; promisify(execFile) under the preload resolves to the injection wrapper; built preload bundle has zero chunk requires; daemon boots and serves getForegroundProcess RPCs end-to-end under --require.
…#7421→stablyai#7499) (stablyai#7505) * Revert "Preload the daemon windowsHide shim via --require; wrap promisify custom (stablyai#7499)" This reverts commit b5710ee. * Revert "Hide console windows for children of the node.exe-hosted daemon (stablyai#7486)" This reverts commit 081cf2f. * Revert "fix(daemon): relocate daemon host image out of the install-dir kill zone (stablyai#7473)" This reverts commit 38c2e2e. * Revert "fix(pty): keep runtime dirs a surviving daemon still uses (stablyai#7463)" This reverts commit 01ad86a. * Revert "Relocate node-pty ConPTY runtime outside the Windows install dir (fixes update-time terminal loss) (stablyai#7421)" This reverts commit 24d599f.
* Show all worktrees across all hosts on mobile Avoid honoring desktop's host-filtering settings since mobile lacks the UI to manage or unhide them. This prevents worktrees from being silently hidden under certain host scopes. Additionally, this removes worktree filtering based on repo metadata, which previously caused worktrees to vanish when same-named repos on different hosts collapsed to a single ID. * fix(daemon): preserve promisify.custom type through wrapChildProcessApi The windows-hidden-console-children test (from stablyai#7499, admin-merged with a failing verify) failed tsgo: promisify(wrapped) resolved to its zero-arg overload because the wrapper erased its argument to a bare variadic function and the fake never statically carried promisify.custom. Preserve the wrapped type via a generic overload (accurate: the wrapper copies the call signature and symbols verbatim) and build the fake as a real CustomPromisify, so promisify routes through the custom overload as it does in production. Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Orca <[email protected]>
Problem
The rc.6 windowsHide shim (#7486) ships in the bundle but does nothing — rc.6 daemons still flash a Windows Terminal window every ~3 seconds. Two independent defeats, found by driving the real probe path on a live rc.6 machine:
require()calls above inlined module code. Confirmed in the shippeddaemon-entry.js: the session chunk (containingwindows-foreground-process-rows.ts, whose module scope capturespromisify(execFile)) evaluates at byte 375; the inlined shim installs at byte 1063. The capture wins; the shim patches nothing anyone uses.util.promisify.custombypasses the wrapper. Node'sexecFilecarries a custom promisify implementation that internally calls the original function. The shim copied that symbol verbatim, sopromisify(execFile)— exactly what the daemon's CIM probes use — returned Node's original, skipping the injection even when the wrapper was reachable.Fix
out/main/windows-hidden-console-children.js, zero chunk requires — verified in the built output) and the daemon fork preloads it withnode --require, which Node guarantees runs before the module graph loads. Immune to bundler ordering by construction. Applied only on the relocated-node.exe host path (Electron hosts already default windowsHide=true).wrapChildProcessApinow wraps each symbol-attached function (the promisify customs) with the same windowsHide-default injection instead of copying them verbatim.Verification (Windows, staged production Node 24 binary)
Ambient rc.6 flashing on the test machine contaminates window-count assertions, so probes set a unique console title (
XVER-FLASH-CANARY) and trials assert on canary-titled Windows Terminal windows only:execFile, no preload: 3/3 trials flash → with preload: 0/6promisify(execFile)(the exact daemon probe shape), no preload: 3/3 flash → with preload: 0/5promisify(execFile)under the preload resolves to the injection wrapper (inspected directly); without it, Node's original--requireboots and servesgetForegroundProcessRPCs end-to-end under a standalone node.exeRollout note
Daemons already running from rc.5/rc.6 keep flashing until replaced (they survive updates by design). One
Manage Sessions → Restart Daemonafter this ships — or updating with no terminals open (staleness check then auto-replaces) — clears it permanently.