Skip to content

fix(windows): remove Orca's agent hooks and PATH entry when uninstalling - #35588

Merged
nwparker merged 4 commits into
mainfrom
nwparker/windows-uninstall-hooks-path
Oct 29, 2026
Merged

nwparker merged 4 commits into
mainfrom
nwparker/windows-uninstall-hooks-path

Conversation

@nwparker

@nwparker nwparker commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​282 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​282
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​212 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​211

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 .orca folder every agent reported a failed hook on every event. If you'd installed the orca command, 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

  • New uninstall-only mode in the app (src/main/startup/agent-hooks-uninstall-preflight.ts), started with --orca-uninstall-remove-agent-hooks. It mirrors the existing --orca-uninstall-release-wsl-holders mode:
    • It runs instead of the app (src/main/index.ts): no window, no single-instance lock, no IPC.
    • It installs the app environment (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.
    • It calls the same removeManagedAgentHooks() as turning off Settings → Agent status hooks. That is file edits only, written only when something changed, with no shell or PowerShell spawned.
    • It exits 0 or 1, and arms a 30 s self-exit first, so it can't leave the uninstaller waiting on an error box.
    • The hook modules are loaded only in this mode, so ordinary startup doesn't pay for them.
  • NSIS customUnInstall, real uninstall only (${ifNot} ${isUpdated}, so updates are untouched). After the app and its daemon are killed:
    • It checks for another Orca install (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 reads Software\<GUID> InstallLocation from both hives with native registry calls (64-bit view). A location other than $INSTDIR whose folder still holds the app counts as another install. A read error other than "no such key" counts as unknown.
    • Only when the answer is definitely "no other install" does it run the installed exe with the flag, ignoring the exit code. "Other" or "unknown" leaves the hooks in place.
    • it removes $INSTDIR\resources\bin, the directory the app registers, from the user PATH (config/nsis/orca-user-path-cleanup.nsh).
  • How the PATH cleanup works:
    • It uses native registry calls only: ReadRegStr / WriteReg(Expand)Str / DeleteRegValue plus RegQueryValueEx for the value type. There's no PowerShell and no reg.exe.
    • It writes only with a value type it actually read (REG_SZ or REG_EXPAND_SZ). If opening the key or querying the type fails, the write is skipped rather than defaulting to REG_SZ.
    • It removes only entries equal to that directory, with or without a trailing \, compared case-insensitively. Every other entry, including empty ones, stays byte-for-byte.
    • An expandable PATH stays REG_EXPAND_SZ. If nothing else remains, the value is deleted, as the app's own removal does.
    • Explorer is notified with WM_SETTINGCHANGE.
    • Narrower match than the app's: NSIS removes only an exact case-insensitive $INSTDIR\resources\bin, with or without a trailing \. The app's samePathEntry also expands variables and normalizes spelling. A differently spelled entry is left behind, never damaged.
    • Truncation guard: if the PATH is as long as NSIS's string limit, the read might have been truncated, so it's left untouched rather than written back short.

Why

  • Why the hooks matter only after the last uninstall: the hook scripts reference nothing in $INSTDIR. They call the system curl.exe and more.com, plus a copy of orca-agent-hook.exe kept 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 ~/.orca is 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.

    • Uninstalling Orca on Windows now removes Orca's hook entries from agents' settings files (the same edit as turning hooks off in Settings) and removes Orca's orca command folder from the user PATH.
    • Updates don't run either step.
    • If the exe fails or hangs, uninstall continues: the exit code is ignored, and the mode self-exits after 30 s.
    • A PATH too long to read safely is left as is, with a harmless leftover entry.

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 the setAppEnvironment line, this test fails.
  • agent-hooks-uninstall-preflight.test.ts:
    • exit code 0 only when no agent reports an error, and 1 on an error or a throw;
    • ordinary launches ignore it;
    • the flag runs removal once and exits 0 with no window, lock or IPC;
    • a setup failure exits 1 once.
    • NSIS contract checks for the other-install skip: the hook exec sits inside ${if} $1 == "none" right after ORCA_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.
    • NSIS contract checks for strict PATH types: the write is gated on a read type ($R8 != "", set only when the query succeeds), with explicit REG_SZ and REG_EXPAND_SZ branches and no fallback write.
    • NSIS contract checks: hook removal runs only in the real-uninstall branch, after the app and daemon are killed, with its exit code popped and unchecked. The PATH macro is included and called once with $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) and nsis-process-check.test.mjs pass.
  • pnpm tc and pnpm run typecheck:ci pass. So do oxlint on src/main/startup, the anti-slop lint, the ast-grep gates, check:process-host-imports and check:code-quality:changed.
  • Not run locally: compiling and running the NSIS script needs Windows. This PR's package (windows) job builds the installer, which compiles the new include. An install → register orca → 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Windows only.
  • Per-machine installs: HKCU and the hook files belong to the user running the uninstall, the same user whose Orca registered them in the usual case.
  • Hooks inside WSL distros and on SSH hosts aren't touched. They use the guarded form and are documented in the uninstall notes.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[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

  1. P2 Uninstall can wait indefinitely ▶

Summary

Windows uninstall now removes shared agent hooks after the last registered Orca install and removes that install's command folder from the user PATH.

  • The last Windows uninstall removes Orca’s agent-hook settings.
  • Each real Windows uninstall removes its command folder from the user’s PATH.

Reviews (5) · Last reviewed commit: "test(windows): register the uninstall pr..." · Reviewed by Greptile

Comment thread config/nsis/orca-installer-hooks.nsh Outdated
; 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'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

@nwparker
nwparker force-pushed the nwparker/windows-uninstall-hooks-path branch from 0a9d536 to bbcac4b Compare October 29, 2026 02:05
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The application now has a flagged startup preflight that removes managed agent hooks and exits with a status based on removal results. Startup skips normal initialization when the preflight handles the launch. During a real uninstall, NSIS checks for another installation and runs the removal command only when none is found. NSIS does not block uninstall on the command’s exit code. It then removes the Orca resources\bin entry from the current user PATH.

Priority: Normal

Merge Risk: Low · up to 5f12c

The new real-remover test can modify a developer's actual Hermes or Grok configuration if their environment points at one. Stub the three remaining path variables to fixture directories before merging. The production uninstall behavior is not affected.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: removing Orca agent hooks and the PATH entry during Windows uninstall.
Description check Passed The description is detailed and covers the user impact, implementation, rationale, testing, limitations, and platform scope. The linked issue is marked N/A despite the template requiring an actual iss…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is detailed and covers the user impact, implementation, rationale, testing, limitations, and platform scope. The linked issue is marked N/A despite the template requiring an actual issue, and the testing checkboxes remain unchecked, but the description is otherwise substantially complete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 5 files.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.
@nwparker
nwparker force-pushed the nwparker/windows-uninstall-hooks-path branch from 9e56951 to e17d0e3 Compare October 29, 2026 02:58
…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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Commits

Reviewing files that changed from the base of the PR and between e17d0e3 and 5f12c28.

Files selected for processing: 2
  • src/main/runtime/construction/runtime-composition-parity.test.ts
  • src/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.

Comment on lines +39 to +41
vi.stubEnv('APPDATA', join(fixture.home, 'AppData', 'Roaming'))
vi.stubEnv('CODEX_HOME', join(fixture.home, '.codex'))
vi.stubEnv('CLAUDE_CONFIG_DIR', '')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Data Integrity & Integration · Quick win

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant