Check for CI environment variable (set by GitHub Actions and most CI
systems) instead of VITEST to skip beforeunload handler registration
during automated tests.
The static cleanup handler was interfering with test lifecycle,
causing the server to be killed during database migration.
Skip registration when VITEST environment variable is set.
### Fixed
- Replaced unreliable taskkill /T with PowerShell Get-CimInstance for child process detection in WindowsProcess.ts
- Fixed orphaned node.exe processes when Obsidian closes by killing child processes before parent
- Added proper cleanup when shell: true creates cmd.exe -> node.exe process tree
### Added
- Static currentProcess field to track active process for cleanup during window close
- Static cleanupHandlerRegistered flag to prevent duplicate event handlers
- beforeunload event handler for synchronous cleanup when Obsidian window closes
- killProcessSync method for immediate process termination without async delays
- registerCleanupHandler method to set up window close event listener
### Changed
- Updated start method to store process reference and register cleanup handler
- Modified stop method to use PowerShell child lookup before killing parent process
- Enhanced error handling with try/catch blocks for PowerShell and taskkill operations
- Add shell: true to spawn options for .cmd file execution on Windows
- Add windowsHide: true to prevent console window from appearing
- Remove detached: true which conflicts with shell: true on Windows
Fixes spawn EINVAL error on Windows when launching opencode.cmd
Set NODE_USE_SYSTEM_CA=1 when spawning the opencode server process.
This allows Bun to use the macOS system keychain for TLS validation,
fixing SSL errors for users on corporate VPNs with custom CAs.