Repository navigation
fix(windows): remove Orca's agent hooks and PATH entry when uninstalling - #35588
Conversation
[Medium impact] The PR appears safe to merge, with the earlier non-blocking concern about uninstall waiting on a blocked file read still open. Findings
SummaryWindows uninstall now removes shared agent hooks after the last registered Orca install and removes that install's command folder from the user PATH.
Reviews (5) · Last reviewed commit: "test(windows): register the uninstall pr..." · Reviewed by Greptile |
| ; Agent hooks on Windows call Orca's scripts by bare path, so take their entries out of each | ||
| ; agent's settings before the files go. Best effort: the exit code never blocks uninstall. | ||
| ; Sync the flag with AGENT_HOOKS_UNINSTALL_FLAG in src/main/startup/agent-hooks-uninstall-preflight.ts. | ||
| nsExec::Exec '"$INSTDIR\${APP_EXECUTABLE_FILENAME}" --orca-uninstall-remove-agent-hooks' |
There was a problem hiding this comment.
Uninstall can wait indefinitely
If the user's home is on an unavailable network share, Claude's readFileSync() can block the JavaScript thread. The 30-second timer then cannot run app.exit(1). This nsExec::Exec call has no external timeout, so uninstall can wait beyond the promised limit.
Put the deadline outside the child process, or move the file work off the thread that runs the timer.
0a9d536 to
bbcac4b
Compare
Walkthrough
Priority: Merge Risk:
|
On Windows most agents' managed hooks, and Claude's status line, call Orca's .cmd scripts by bare path (to avoid starting PowerShell per event), and the uninstaller removed neither those entries nor the `orca` command's user PATH entry. Once %USERPROFILE%\.orca went, every agent failed a hook on each event. A real uninstall (not an update) now runs the installed exe with --orca-uninstall-remove-agent-hooks, mirroring the WSL holder release: no window, lock or IPC, file edits only, a 30 s self-exit, and an exit code the uninstaller ignores. It then drops $INSTDIR\resources\bin from the user PATH with native registry calls, keeping every other entry and the value's type, and skipping the edit if the read could have been truncated.
…ip PATH edits of unknown type The hook scripts live in the shared ~/.orca\agent-hooks and reference nothing in $INSTDIR (they call system curl/more and a copy of orca-agent-hook.exe there), so they outlive an uninstall; the entries only break once that folder is removed. The last Orca install for this user now takes them out: the uninstaller reads the other per-user/per-machine registration (every channel shares one app GUID) with native registry calls, and skips the removal if another install still has the app or a read fails. PATH cleanup still runs, as it is per $INSTDIR. PATH cleanup now writes only with a value type it actually read (REG_SZ or REG_EXPAND_SZ); a failed open or query skips the write instead of assuming REG_SZ.
…emovers run The uninstall mode skips the app's own preflight, so setAppEnvironment was never called. Claude's remover then threw at getAppEnvironment() right after writing settings.json: its agent-view keybinding stayed in every profile home and its status-line marker stayed too. Install ElectronAppEnvironment right after the AppData path, as main-process-preflight does. A new test runs every agent's real remover in that mode with no environment preset; none warns, the mode exits 0, and Claude's agent-view binding and status-line marker are gone.
9e56951 to
e17d0e3
Compare
…its real-remover test off real homes The uninstall hook-removal preflight installs the app environment, so it joins HOST_PORT_SOURCES. Its real-remover test now points HOME, USERPROFILE, ORCA_USER_DATA_PATH, XDG_CONFIG_HOME, APPDATA, CODEX_HOME and CLAUDE_CONFIG_DIR at the fixture: on Linux CI the Codex runtime home resolved from the runner's XDG_CONFIG_HOME, which the real-agent-home write guard rejected.
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
36ba4801-2d4b-49b0-bd8d-d1ef655cb409
Files selected for processing: 2-
src/main/runtime/construction/runtime-composition-parity.test.tssrc/main/startup/agent-hooks-uninstall-preflight-real-removers.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
-
| vi.stubEnv('APPDATA', join(fixture.home, 'AppData', 'Roaming')) | ||
| vi.stubEnv('CODEX_HOME', join(fixture.home, '.codex')) | ||
| vi.stubEnv('CLAUDE_CONFIG_DIR', '') |
There was a problem hiding this comment.
Isolate the remaining agent home paths.
On Windows, LOCALAPPDATA can direct the Hermes remover to the developer’s real configuration. HERMES_HOME and GROK_HOME can do the same on any platform. The test can then delete managed plugins or rewrite real hook settings. Stub all three paths inside the fixture. See src/main/hermes/hermes-default-home.ts:35-51, src/main/hermes/hook-service.ts:211-240, and src/shared/grok-session-paths.ts:36-41. (raw.githubusercontent.com)
ELI5
On Windows, Orca adds small "status hook" entries to your agents' settings, for Claude, Codex, Gemini and others, plus Claude's status line. They run Orca's scripts from
%USERPROFILE%\.orca\agent-hooks. Those scripts stay after an uninstall, but the entries did too, so once you deleted the.orcafolder every agent reported a failed hook on every event. If you'd installed theorcacommand, uninstalling also left its folder on your PATH.When you uninstall the last Orca on your Windows account, the uninstaller now removes Orca's hook entries. Any uninstall also removes that install's own PATH entry. If another Orca install is still there, its agents keep their hooks.
What Changed
src/main/startup/agent-hooks-uninstall-preflight.ts), started with--orca-uninstall-remove-agent-hooks. It mirrors the existing--orca-uninstall-release-wsl-holdersmode:src/main/index.ts): no window, no single-instance lock, no IPC.setAppEnvironment(new ElectronAppEnvironment())), as the app's own preflight does. That's needed because Claude's remover reads Orca's data folder through it for its profile homes.removeManagedAgentHooks()as turning off Settings → Agent status hooks. That is file edits only, written only when something changed, with no shell or PowerShell spawned.customUnInstall, real uninstall only (${ifNot} ${isUpdated}, so updates are untouched). After the app and its daemon are killed:config/nsis/orca-other-install-check.nsh). Every channel shares one app GUID, so a second install for the same user can only be the other registration: per-user (HKCU) beside per-machine (HKLM), or the reverse. The check readsSoftware\<GUID>InstallLocationfrom both hives with native registry calls (64-bit view). A location other than$INSTDIRwhose folder still holds the app counts as another install. A read error other than "no such key" counts as unknown.$INSTDIR\resources\bin, the directory the app registers, from the user PATH (config/nsis/orca-user-path-cleanup.nsh).ReadRegStr/WriteReg(Expand)Str/DeleteRegValueplusRegQueryValueExfor the value type. There's no PowerShell and no reg.exe.REG_SZorREG_EXPAND_SZ). If opening the key or querying the type fails, the write is skipped rather than defaulting toREG_SZ.\, compared case-insensitively. Every other entry, including empty ones, stays byte-for-byte.REG_EXPAND_SZ. If nothing else remains, the value is deleted, as the app's own removal does.WM_SETTINGCHANGE.$INSTDIR\resources\bin, with or without a trailing\. The app'ssamePathEntryalso expands variables and normalizes spelling. A differently spelled entry is left behind, never damaged.Why
Why the hooks matter only after the last uninstall: the hook scripts reference nothing in
$INSTDIR. They call the systemcurl.exeandmore.com, plus a copy oforca-agent-hook.exekept in~/.orca\agent-hooks. So the scripts keep working, as harmless no-ops outside Orca, after the app is gone. The entries break only once~/.orcais deleted. While another Orca for the same user remains, its agents still need them.Why the exe handles the hooks: hook removal has to understand each agent's settings format, and the app already does that correctly. That's the code Settings uses. Reimplementing it in NSIS would mean a second, drifting copy.
Why not guard the hooks instead: a guard that works in every Windows hook host would mean starting PowerShell on every hook event, which our Windows EDR rules rule out.
Why NSIS does the PATH edit: it's the uninstaller's own state, NSIS can edit it natively, and it doesn't need the exe to start.
Flag-off: N/A. This is the Windows uninstaller, not WSL-gated.
User risk: low.
orcacommand folder from the user PATH.Linked Issue
N/A. Found in the uninstall audit of what Orca writes outside its own folders.
Visual Proof
N/A. No UI change.
Testing
agent-hooks-uninstall-preflight-real-removers.test.ts: runs every agent's real remover through the uninstall mode, with no app environment preset, against a temporary home holding Claude's agent-view binding and status-line marker. No remover warns, the mode exits 0, the binding is removed, and the status-line marker is gone. Without thesetAppEnvironmentline, this test fails.agent-hooks-uninstall-preflight.test.ts:${if} $1 == "none"right afterORCA_OTHER_INSTALL_STATE. The check reads both hives'InstallLocation, excludes$INSTDIR, requires the app to exist there, reports "unknown" on any error other than not-found, and spawns nothing.$R8 != "", set only when the query succeeds), with explicitREG_SZandREG_EXPAND_SZbranches and no fallback write.$INSTDIR\resources\bin, which matches the app's registered directory (getBundledLauncherPath('win32')'s folder). The PATH code spawns no process, keeps the value type, writes only after a removal, and carries the length guard.src/main/startup/(763 tests) andnsis-process-check.test.mjspass.pnpm tcandpnpm run typecheck:cipass. So do oxlint onsrc/main/startup, the anti-slop lint, the ast-grep gates,check:process-host-importsandcheck:code-quality:changed.package (windows)job builds the installer, which compiles the new include. An install → registerorca→ uninstall run on a Windows box is still worth doing before release.AI Disclosure
Review
Uninstaller and agent hook path: needs two reviewers.
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)