Repository navigation
fix(windows): preserve relocated terminals and native process scans - #22872
Conversation
The Windows terminal daemon runs from a copy of the app under %LOCALAPPDATA%\Orca\daemon-host\<version>. That copy took node-pty but not @vscode/windows-process-tree, so the daemon's bare require of the addon found nothing and every process-table read (foreground tracking, descendant sweeps) fell back to a powershell.exe Get-CimInstance scan (#16905). - Copy the addon's runtime files (package.json, lib/, the .node binary) into the host; the ~25MB of gyp intermediates beside them are filtered out. - Treat a host missing those files as unmaterialized, so hosts built before this are rebuilt, and skip relocation if the install itself lacks them. - Log the daemon's native/CIM capability at startup and warn once when the process table falls back to CIM. Revives #19525 on current main.
There was a problem hiding this comment.
ℹ️ No critical issues — one design question and one stale reference, both below. The fix itself is well constructed and the regression tests are strong.
Reviewed changes — full diff at 5f34c0c (7 files): the daemon-host copy plan was extracted into its own module and extended to mirror @vscode/windows-process-tree, with a new source/mirror validity check, a startup capability log, and a once-per-process CIM-fallback warning.
- Copy plan extracted to
daemon-host-manifest.ts—buildDaemonHostManifest,executeManifest,toPosixRelative,destPath,daemonHostExeName,CopyOpandDaemonHostSourcesmoved out ofdaemon-host-relocation.ts. The new process-tree op mirrors the package filtered to its runtime files. - Host validity now requires the addon —
getRelocatedDaemonHostrejects a mirror missingpackage.json/lib/index.js/build/Release/windows_process_tree.node;materializeRelocatedDaemonHostrefuses to copy at all when the install lacks them. - Diagnostics —
daemon-entrylogswindows-process-table {native}on win32;readOneSnapshotwarns once per process when it falls back to the CIM scan. - Docs —
windows-daemon-host-relocation.mdgains the "every native module must be in the copy plan" invariant. - Tests — copy-plan layout, the mirrored addon plus
createRequire.resolve('@vscode/windows-process-tree')from the relocatedchunksdir, mirror/source refusal, rematerialize-on-loss, and the once-per-process warning.
ℹ️ Update-survival now depends on the addon being present in the install
The new source check in materializeRelocatedDaemonHost means a Windows host whose install is missing the addon no longer relocates at all, so its daemon is killed on the next update and terminals cold-restore. Before this change that host still got a relocated daemon (it just flashed PowerShell on each scan). Since the addon is the native file an EDR/AV is most likely to quarantine, this couples the update-survival feature to exactly the file the subsystem's environment tends to remove.
Technical details
# Relocation skipped when the install loses the addon
## Affected sites
- `src/main/daemon/daemon-host-relocation.ts:193` — `missingProcessTreeFiles(sources.windowsProcessTreeDir)` returns null before staging.
- `src/main/daemon/daemon-host-relocation.ts:171` — the mirror check that makes materializing-without-the-addon self-defeating (it would be refused and recopied on every launch).
## Behavior change
- Pre-PR: addon absent from install → host still materialized → daemon survives updates, process-table reads use the `powershell.exe` CIM fallback.
- Post-PR: addon absent from install → no host → daemon forks from the install dir → killed on update, terminals cold-restore, and the reads still use CIM (the addon is absent either way).
## Open questions for the human
- Is dropping update-survival the intended trade for hosts whose addon is quarantined? `materializeRelocatedDaemonHost` cannot simply copy anyway, because `getRelocatedDaemonHost` would then refuse the mirror every launch — avoiding that loop needs the marker to record which optional files were copied, or the mirror check to only require what the source had.
- `config/packaged-runtime-node-modules.cjs:569` fails a win32 *build* without the addon, but a build-time check cannot see a runtime quarantine.ℹ️ Nitpicks
config/scripts/electron-builder-markdown-associations.test.mjs:109still citesdaemonHostExeName, daemon-host-relocation.ts, but that function now lives indaemon-host-manifest.ts.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughThe daemon-host copy manifest now includes the Windows process-tree package and its required files. Relocation rejects incomplete source or copied packages, and tests cover rebuilding and validating relocated hosts. Windows daemon startup logs native process-table availability. The CIM fallback warning is limited to once until native-reader state resets. The Windows update-survival workflow and harness now record environment probes and process liveness. Priority: ⬆️ High Merge Risk: ⚪ Minimal · up to No code defect identified here blocks merging. The planned update-survival verification remains a separate release decision. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to The change should reduce repeated PowerShell process scans, but it also makes update survival depend on the native process-table package being present. If that package is incomplete, the daemon can run from the install directory and lose its protection from the updater’s process sweep. No new attacker-reachable entrypoint was established. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation Issue Full details: Docstring CoverageExplanation Docstring coverage is 54.17% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 9 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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 |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the incremental delta since the prior pullfrog review at 5f34c0c (commits 407f2c6..b345597). Product code is unchanged; this is harness and CI only.
- Strict app close for survival proofs —
closeAppgained a third{ allowForceKill }option (defaulttruepreserves prior behavior). Survival proofs passfalse, which disables the launcher-stub PID fallback, rejects a close with no authoritative Electron PID, recordscloseStatusas resolved/rejected/pending, and rejects a resolvedapp.close()while the main PID is still alive. Strict failures emitstrict-close-failedevidence and never tree-kill. - PID evidence on close failure —
readClosePidEvidencereportslive/exited/unverifiablefor the main and launcher PIDs, with the launcher's exit/signal codes and stdio state. - New shutdown tests —
app-shutdown.test.mjscovers the rejected close, the 45 s timeout path (fake timers, timer cleanup), and the resolved-close-live-PID rejection. Runs green locally. - Workflow cache + diagnostics — installer cache split into
cache/restoreplus an explicitcache/saveguarded bycache-hit != true; addsORCA_BACKGROUND_LAUNCH=1,DEBUG=pw:browser, an informational x86 PowerShell probe replay, andTee -Append. - Pre-install control window —
run.mjsholds 60 s after the graceful close and logs daemon/marker liveness before and after install, so survival loss can be localized.
The strict close is what surfaced the unresolved app-shutdown hang; the harness now reports it instead of masking it with a tree kill, matching the author's stated hold.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the delta since the prior pullfrog review at b345597 (commit 7d4b46a, harness and CI only; product code still unchanged at 5f34c0c).
- Accept an OS-verified close when inherited pipes stall Playwright — the strict close path now returns (logging
close-verified-by-pids) whencloseStatus === 'pending'and both the main and launcher PIDs reportexited. A rejected close, or a live/missing/unverifiable PID, still fails and still never tree-kills. This matches the observed failure: both processes exited but the surviving daemon held the launcher's pipes open. - Shutdown tests — adds the accept-on-verified-exit case plus an
it.eachfor a live or unverifiable launcher with the main exited, and restores theisPidAlivemock inafterEach. 12 focused harness tests pass. - Workflow cache key and ordering — the installer key now also hashes
resources/**,mobile/**,patches/**andpnpm-workspace.yaml, and the dependency install runs after the cache restore so postinstall artifacts undernative/cannot vary the key.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the incremental delta since the prior pullfrog review at 7d4b46a (commit a4d335c, harness and CI only; product code still frozen at 5f34c0c).
- Injected the shutdown helper's process primitives.
closeAppnow takes aprocessesoption (isPidAlive+killTree) defaulting to the realappShutdownProcesses, and the strict path plusreadClosePidEvidenceread through it. Real-run behavior is unchanged; the shutdown tests no longer mocknode:child_processordaemon-processes.mjs. - Pinned the best-effort cleanup path. A new test asserts the default force-kill fallback still fires exactly once (
killTree(123)) when force-kill stays enabled, so the injection cannot silently disarm ordinary cleanup. All 7 tests inapp-shutdown.test.mjspass. - Added opt-in installer/uninstaller tracing.
trace-installer-branches.mjsresolvesapp-builder-lib'sallowOnlyOneInstallerInstance.nsh, validates every anchor (replaceOncethrows on drift), and appends PowerShell-availability, policy, selected-branch and find/kill-result lines through a self-containedORCA_E2E_TRACEmacro. It only writes on a disposable Windows CI checkout (GITHUB_ACTIONS === 'true' && win32) unless--check;--checkvalidates clean against the installed electron-builder 26.15.3. - Wired the trace into the workflow. A
trace_installerboolean input selects atrace-<tracer-hash>-installer cache key so a traced installer can never be reused as a normal one, setsORCA_E2E_NSIS_TRACEon the harness step, and uploads the trace log with the survival artifacts.
The tracer's injected NSIS had not yet produced a green build at review time (the opt-in trace run was in flight), but that run is self-announcing: an anchor or macro failure fails the instrument/build step rather than passing silently.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the incremental delta since the prior pullfrog review at a4d335c (commit ad571cf, plus a merge of origin/main). This carries the first product change since 5f34c0c.
- Replaced the installer's execution-policy probe with a capability probe.
config/nsis/orca-process-check.nshdefinescustomCheckAppRunning, which runs an inlineGet-CimInstance -ClassName Win32_Processundertry/catch; success selects upstream's path-scoped sweep, any other result retains the image-name fallback. Upstream'sFIND_PROCESS/KILL_PROCESS/ retry / install-mode logic is inserted unchanged, and defining the hook makesallowOnlyOneInstallerInstance.nshskip its owngetProcessInfo.nshinclude andVar pidvia!ifmacrondef. - Wired the hook through the shared include.
orca-installer-hooks.nshincludes the new file. The include order (custom include emitted insharedHeader, beforeinstaller.nsiwhich pulls inallowOnlyOneInstallerInstance.nsh) is what makes the override and itsVardeclarations legal, so there is no duplicateVar pid. - Restricted-policy and release-migration CI vehicle.
win-update-survival-e2e.ymlgainspolicy(inherited | Restricted) andfrom_releaseinputs; the harness is launched through a smallnode --input-type=module -eshim that setsPSExecutionPolicyPreferencefor its children only, and--from-releaseis already supported bycli-args.mjs/installer-steps.mjs. - Retargeted tracing and added tests.
trace-installer-branches.mjsnow patches the capability hook instead of the upstream probe;config/scripts/nsis-process-check.test.mjsasserts the hook structure and, on Windows, runs the real captured probe under Restricted for bothSysWOW64andSystem32(permit and failed-query cases) — coverage that can actually fail.
Orca's own CIM fallback uses -Command inline (windows-process-table-cim-scan.ts:93), so the Restricted policy injection cannot break the fallback for the wrong reason. Packaged survival/trace runs and the documented first-upgrade cold-restore limit remain the author's merge gate, as stated in the PR body.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the delta since the prior pullfrog review at ad571cf (commit 17218e3, 2 files).
- Aligned the probe's PowerShell profile behavior with upstream.
config/nsis/orca-process-check.nshnow invokes"$PowerShellPath" -Command "…"without-NoProfile -NonInteractive, so the capability probe loads the same profile as the upstreamFIND_PROCESS/KILL_PROCESScalls it selects between. This closes the gap where the probe could exit 0 while the real query still failed under the loaded profile and the fallback was never reached. - Made the test assert that alignment against the real upstream template.
config/scripts/nsis-process-check.test.mjsnow resolves the installedapp-builder-liballowOnlyOneInstallerInstance.nsh, extracts itsFIND_PROCESSmacro, and asserts the probe's argument list equals that macro's. Re-adding a profile flag to the probe (or an upstream change to one) now fails the test instead of passing silently.
The Windows Restricted-policy cases are unchanged and still exercise the real captured command. Packaged survival/trace runs remain the author's merge gate, as stated in the PR body.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the delta since the prior pullfrog review at 17218e3 (commit cd935c8, 2 files).
- Use a native NSIS separator for the process-check include —
orca-installer-hooks.nshnow!includesorca-process-check.nshwith a backslash (${__FILEDIR__}\…) instead of/, matching the separator${__FILEDIR__}expands to undermakensisand clearing the include-separator error seen in the preceding package attempt. The structuraltoContainassertion innsis-process-check.test.mjswas updated in lockstep.
The structural test passes locally (2 passed, 4 Windows-only skipped). Windows installers are only ever compiled on windows-2022 (the release build matrix win leg, both win survival workflows, and pr.yml package_windows), so the hardcoded backslash cannot reach a POSIX makensis. The two informational body items from the first review remain open and unchanged as previously reported.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the delta since the prior pullfrog review at cd935c8 (commit be01dee, harness only; product code still frozen at 5f34c0c).
- Dismiss the session-search feature tip too.
dismissKnownOverlaysnow loops overFEATURE_TIP_DIALOG_TITLES('Let agents drive Orca with the Orca CLI'and'Search every agent session') and closes whichever dialog is visible, replacing the single-title constant. The dismissal stays escape-free, so it still never injects a keypress into a restored terminal. - Extended test coverage.
app-driver.test.mjsruns the window-Close and escape-free dismissal tests over both tip titles viait.each, and adds a test that drivesensureTerminalthrough a first "Create worktree" click intercepted by the late-appearing session-search tip, asserting it is dismissed, the composer is submitted once, and no keypress is sent.
app-driver.test.mjs passes (8/8). The two informational body items from the first review (the update-survival trade-off when the install lacks the addon, and the stale daemonHostExeName doc reference) remain open and unchanged.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
Windows terminals repeatedly launch PowerShell because their relocated runtime omits the native process-list addon. An independent installer bug also kills that runtime during some updates. This PR copies the missing addon and checks whether the installer can actually query Windows processes before choosing how to close the app.
Merge risk: medium — installer process selection changes. Native-addon verification, packaged update survival under inherited and Restricted policies, crash survival and expected released-base cold restore all pass. First upgrade can restart terminals because it runs the old uninstaller.
What Changed
Get-CimInstance Win32_Processcapability probe. Successful queries use the existing path-scoped process check; failed queries retain the existing fallback. Upstream process selection, retries and installation-mode handling stay in use.Why
Resolving the addon through the install directory would tie terminals to files replaced during updates. Copying its runtime files keeps the existing relocation design.
Installer trace 36227222390 proves the old policy probe selected the image-name fallback and successfully killed the relocated
Orca.exe. The daemon and marker had survived verified app exit and a 60-second control. The genuine-uninstall guard worked.Restricted policy permits inline commands even though it disallows script files. The new probe measures the capability the installer needs without changing policy, renaming the executable or forcing a branch when PowerShell is unavailable.
Linked Issue
Crash Scan 24 console-flash report; supersedes #19525 and the daemon-addon portion of #17115. #17115 also changes an independent Resource Manager resource sweep, outside this PR. Installer survival failure discovered while verifying this fix.
Visual Proof
Actual awin copy-plan and process-reader execution: addon withheld →
native:false, 507 rows, 307 ms and PowerShell fallback; addon copied →native:true, 504 rows, 45 ms and no fallback. Both exited 0; temporary host removed. No new visual console-flash recording is claimed.Testing
Windows: 91 focused product tests passed, 1 skipped. The original policy probe fails both x86/x64 regression cases under child-only Restricted policy; the candidate passes all six tests, including real failed-query handling. The parent policy is unchanged.
Current local head: 128 focused tests passed, 4 Windows-only cases skipped; node typecheck and changed-code quality pass. Shutdown harness includes 13 passing tests. Trace anchors, YAML, formatting and lint pass. The corrected hook compiles through the actual NSIS compiler in both installer and uninstaller modes. The preceding package attempt caught a Windows include-separator error, now corrected.
Packaged checks on
be01dee5c2(harness-only revision):The preceding packaged runs built and installed successfully, then stopped before terminal creation because the session-search announcement hid the workspace opener. The harness now dismisses that exact dialog; 29 focused harness checks pass.
Earlier restart, crash-survival and historical cold-restore checks passed before the installer correction. Those do not substitute for the new packaged runs.
Review
The missing-addon cause and the installer's killing branch are established independently. The exact environment difference between the installer's original policy probe and a direct PowerShell replay remains unexplained; no causal claim depends on that discrepancy.
Agent skill upstream boundary
Notes
Migration limit: an update executes the old installed uninstaller, which retains its old process check. The released-base test confirms loss of the old processes during the install interval and working cold restore afterward. Its released uninstaller was uninstrumented, so that run alone does not prove the exact internal kill branch. A new installer cannot retroactively repair the old binary. A genuinely unavailable CIM query also retains cold restore.
The addon change takes effect when the terminal daemon restarts. Ordinary app quit preserves it. Non-Windows relocation and remote wire/SSH ownership are unchanged.
Checklist