fix(windows): cross-platform tests and safer MCP orphan cleanup - #390
Open
dakshagarwal76 wants to merge 2 commits into
Open
fix(windows): cross-platform tests and safer MCP orphan cleanup#390dakshagarwal76 wants to merge 2 commits into
dakshagarwal76 wants to merge 2 commits into
Conversation
Add scripts/run-vitest.mjs so pnpm test:run works on Windows PowerShell. Match orphaned task-management-mcp processes by command line instead of window title. Add unit tests for the Windows secret broker PowerShell wrapper. Co-authored-by: Cursor <cursoragent@cursor.com>
Extend Windows shutdown-orphans test timeout for slow Get-CimInstance. Use accurate shutdown log message for best-effort MCP cleanup. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Pull request overview
This PR improves Windows compatibility by adding a cross-platform Vitest launcher, making Windows orphan MCP cleanup safer, and adding unit tests around Windows-specific wrappers and shutdown behavior.
Changes:
- Add
scripts/run-vitest.mjsand switchpnpm test*scripts to use it (so tests run from Windows PowerShell). - Refactor Windows orphan
task-management-mcpcleanup intosrc/main/shutdown-orphans.tsand call it from main shutdown. - Extract
buildWindowsSecretShellScript()and add unit tests for Windows PowerShell wrapper + orphan cleanup.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| WINDOWS_PORT_LOG.md | Updates Windows port “known issues” notes to reflect new test coverage and cleanup approach. |
| src/main/shutdown-orphans.ts | Centralizes cross-platform orphan MCP cleanup logic and exposes the kill command for tests. |
| src/main/shutdown-orphans.test.ts | Adds tests for kill-command selection and shutdown behavior. |
| src/main/secret-broker.ts | Extracts Windows PowerShell wrapper script generation into a testable function. |
| src/main/secret-broker.test.ts | Adds unit tests validating the generated PowerShell wrapper script content. |
| src/main/index.ts | Replaces inline orphan cleanup with killOrphanedMcpProcesses() call. |
| scripts/run-vitest.mjs | Introduces a cross-platform Electron-as-Node Vitest launcher. |
| package.json | Updates test scripts to use the new launcher. |
| CONTRIBUTING.md | Documents the cross-platform test launcher behavior for contributors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+3
to
+4
| const WIN_ORPHAN_MCP_PS_COMMAND = | ||
| 'Get-CimInstance Win32_Process -Filter "Name=\'node.exe\'" | Where-Object { $_.CommandLine -like \'*task-management-mcp*\' } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }' |
Comment on lines
+1
to
+2
| import { describe, expect, it } from 'vitest' | ||
| import { getOrphanMcpKillCommand, killOrphanedMcpProcesses } from './shutdown-orphans' |
Comment on lines
+169
to
+172
| export function buildWindowsSecretShellScript(debugLogPath: string): string { | ||
| const debugLog = debugLogPath.replace(/\\/g, '\\\\') | ||
|
|
||
| const script = `# 20x Secret Shell Wrapper (Windows PowerShell) | ||
| return `# 20x Secret Shell Wrapper (Windows PowerShell) |
Comment on lines
+17
to
+18
| expect(script).toContain('^export\\s+([^=]+)=(.*)$') | ||
| expect(script).toContain('[Environment]::SetEnvironmentVariable') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/run-vitest.mjssopnpm test:runworks on Windows PowerShelltask-management-mcpcleanup to match by command line instead of window titleRelated Issue
Windows port improvements (see WINDOWS_PORT_LOG.md known issues)
Changes
scripts/run-vitest.mjs— cross-platform Vitest launchersrc/main/shutdown-orphans.ts— safer Windows MCP process cleanupsrc/main/secret-broker.ts— extract testablebuildWindowsSecretShellScript()package.json— test scripts use new launcherCONTRIBUTING.md— note about cross-platform test commandsTesting
pnpm typecheckpasses on Windowspnpm test:runworks in PowerShellshutdown-orphans.test.tsandsecret-broker.test.tspass