Skip to content

Conversation

@StillKnotKnown
Copy link
Owner

Summary

Fixes hang on Windows after "Environment override check" log by replacing hardcoded bash commands with platform-aware shell syntax.

Problem

On Windows, the terminal would hang indefinitely after logging "Environment override check" because buildClaudeShellCommand() was hardcoded to use bash -c commands that don't exist on Windows.

Solution

  • Windows: Uses cmd.exe/PowerShell compatible syntax:

    • cls instead of clear
    • call to execute .bat temp files
    • set for environment variables
    • del for file cleanup
    • .bat extension for temp files with \r\n line endings
  • Unix/macOS: Preserves existing bash syntax (unchanged):

    • clear, source, export, rm -f
    • Shell temp files with \n line endings

Changes

  • Modified buildClaudeShellCommand() to detect platform and generate appropriate commands
  • Added generateTokenTempFileContent() helper for DRY
  • Added getTempFileExtension() helper for DRY
  • Added error handling with 10s timeout protection in invokeClaudeAsync()
  • Added 7 Windows-specific tests (30 total tests passing)

Test Plan

  • All 30 tests in claude-integration-handler.test.ts passing
  • TypeScript compilation succeeds (0 errors)
  • Production build succeeds
  • ESLint passes (0 errors)
  • Cross-platform paths validated (uses path.join(), os.tmpdir())

Linear Ticket

Resolves ACS-261

…n (ACS-261)

Fixes hang on Windows after "Environment override check" log by replacing
hardcoded bash commands with platform-aware shell syntax.

- Windows: Uses cmd.exe syntax (cls, call, set, del) with .bat temp files
- Unix/macOS: Preserves existing bash syntax (clear, source, export, rm)
- Adds error handling and 10s timeout protection in async invocation
- Extracts helper functions for DRY: generateTokenTempFileContent(),
  getTempFileExtension()
- Adds 7 Windows-specific tests (30 total tests passing)
@StillKnotKnown
Copy link
Owner Author

Superseded by upstream PR: AndyMik90#1152

StillKnotKnown pushed a commit that referenced this pull request Jan 18, 2026
…ik90#1259)

* fix(windows): prevent zombie process accumulation on app close

- Use taskkill /f /t on Windows to properly kill process trees
  (SIGTERM/SIGKILL are ignored on Windows)
- Make killAllProcesses() wait for process exit events with timeout
- Kill PTY daemon process on shutdown
- Clear periodic update check interval on app quit

Fixes process accumulation in Task Manager after closing Auto-Claude.

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* fix(windows): extract killProcessGracefully utility with timer cleanup

- Extract shared killProcessGracefully() to platform module
- Fix Issue #1: Move taskkill outside try-catch scope
- Fix Issue #2: Track exit state to skip unnecessary taskkill
- Fix Issue #3: Add GRACEFUL_KILL_TIMEOUT_MS constant
- Fix Issue #4: Use consistent 5000ms timeout everywhere
- Fix Issue #5: Add debug logging for catch blocks
- Fix Issue AndyMik90#6: Log warning when process.once unavailable
- Fix Issue AndyMik90#7: Eliminate code duplication across 3 files
- Fix timer leak: Clear timeout on process exit/error, unref timer

Add comprehensive tests (19 test cases) covering:
- Windows taskkill fallback behavior
- Unix SIGTERM/SIGKILL sequence
- Timer cleanup and memory leak prevention
- Edge cases and error handling

Co-Authored-By: Claude Opus 4.5 <[email protected]>

---------

Co-authored-by: Claude Opus 4.5 <[email protected]>
Co-authored-by: Andy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants