Skip to content

fix: avoid PowerShell startup for Muse Windows hooks - #26734

Closed
1aifanatic wants to merge 1 commit into
stablyai:mainfrom
1aifanatic:fix/muse-windows-hook-launcher
Closed

1aifanatic wants to merge 1 commit into
stablyai:mainfrom
1aifanatic:fix/muse-windows-hook-launcher

Conversation

@1aifanatic

Copy link
Copy Markdown
Contributor

ELI5

Muse no longer starts PowerShell for every status update on ordinary Windows profile paths. Its existing batch script sends the update directly, reducing per-event process startup overhead.

What Changed

Use the existing Windows direct batch launcher for Muse hooks. It normalizes drive-letter paths for both cmd.exe and Git Bash. Paths requiring special quoting retain the existing fallback. The batch script already checks for Orca's environment before posting with the system curl executable.

Why

Reuse the launcher already used by Claude instead of introducing a second quoting implementation or changing the hook transport. A bare backslash path failed the real Git Bash test, so the shared cross-shell launcher is necessary.

Linked Issue

Fixes #26717

Visual Proof

N/A — background hook process launch only; no visual or interaction change.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Windows, Node 24.21.0, with ORCA_BACKGROUND_LAUNCH=1:

  • 10 focused tests pass in windows-hook-payload-delivery.test.ts and windows-direct-cmd-hook-command.test.ts.
  • The Muse regression fails before the fix because its registered command always invokes PowerShell.
  • Live cmd.exe and Git Bash tests install into a temporary home and verify byte-exact delivery of multi-kilobyte Unicode JSON, correct token and pane identity, expected stdout, and successful exits without posting outside Orca.
  • The shared launcher tests cover paths that require fallback.
  • Formatting, focused Oxlint and the changed-code-quality gate pass.
  • The existing installer utility suite passed (55 tests; 7 skipped).

Full lint/test/build remain unverified locally: dependency installation stopped at the Windows registry native build because Visual Studio C++ tools are absent. The full Node typecheck exhausted memory; a constrained retry was stopped after more than ten minutes at roughly 4.7 GB. Full CI and native macOS/Linux coverage remain outstanding.

AI Disclosure

GPT-6 was used to investigate, implement, test and review this change.

Review

The change is guarded by Windows platform detection. Local macOS/Linux and remote SSH commands retain their POSIX launcher; no remote wire changes. The shared Windows launcher keeps the existing fallback for unsafe, Unicode and UNC paths. Other integrations are unchanged, and Claude's live delivery test still passes. No workspace Git assumptions or UI changes. Ordinary paths remove a per-event interpreter process; payloads still travel through stdin to the existing authenticated loopback endpoint. No new command interpolation or dependencies.

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

Specially quoted paths retain PowerShell compatibility; the fast path covers safe drive-letter paths.

Author

X: @1aifanatic

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)

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Walkthrough

On Windows, Muse managed hook commands now prefer a direct-CMD wrapper and fall back to the existing Windows wrapper when unavailable. The payload-delivery test now covers Claude and Muse installations under cmd.exe and Git Bash. It checks POST payloads, pane keys, tokens, output, exit status, and behavior without Orca environment variables.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to 99ae0

Muse Windows hooks now avoid starting PowerShell for ordinary drive-letter paths and keep the existing fallback otherwise. The only open item is a minor test-guard issue that could cause a false failure when the temp directory is a UNC path.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: avoiding PowerShell startup for Muse Windows hooks.
Description check Passed The description includes the required sections, linked issue, user-facing change, rationale, testing details, limitations, cross-platform considerations, AI disclosure, and checklist status. It also e…
Linked Issues check Passed Issue #26717 requires Muse Windows hooks to avoid PowerShell on the normal path, post with the existing curl.exe batch implementation, and stop when the Orca variables are absent. `getMuseManagedComma…
Out of Scope Changes check Passed The changes stay within issue #26717. The production change only selects the existing direct Windows launcher for local Muse hooks. The test changes add Muse coverage and preserve Claude launcher cove…
  • Fix all pre-merge checks with AI
  • Autopilot · 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.

@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
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e9012562-bc07-4e26-b281-f89b94bdb008
📥 Commits

Reviewing files that changed from the base of the PR and between 56cdd67 and 99ae06b.

📒 Files selected for processing (2)
  • src/main/agent-hooks/windows-hook-payload-delivery.test.ts
  • src/main/muse/hook-settings.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

}
// ...with one exception: a cmd-safe profile must reach the script with no interpreter in
// front of it, or #18875's per-event PowerShell start-up has quietly come back.
if (WINDOWS_CMD_SAFE_PATH.test(join(home, '.orca', 'agent-hooks', provider.script))) {

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Match the direct-CMD path guard in this assertion.

If tmpdir() is a cmd-safe UNC path, this condition is true, but wrapWindowsDirectCmdHookCommand returns null because the path has no drive letter. The intended PowerShell fallback then fails this test. Require a drive-letter path here as well, so the test accepts the documented fallback.

@nwparker

nwparker commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Thanks @1aifanatic — your direct-launcher change is included in #26755, with Naveen Chatlapalli credited as a co-author. That PR also refreshes existing installations and has passed Windows verification and CI. Closing this as superseded; #26755 is still awaiting merge.

@nwparker nwparker closed this Oct 9, 2026
nwparker added a commit that referenced this pull request Oct 9, 2026
Run Muse Windows hooks through the existing direct launcher on safe profile paths and refresh managed installations. Keep the PowerShell compatibility fallback for paths requiring special quoting. Verified on Windows; CI passed.

Adapted the direct-launcher change from community PR #26734.

Co-authored-by: Naveen Chatlapalli <[email protected]>
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.

[Bug]: Muse hooks on Windows start powershell.exe -EncodedCommand on every event before checking whether Orca is listening

2 participants