fix(hooks): prevent terminal I/O blocking from hung Kitty subprocesses #473
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.
Fix for issue #464.
The StopOrchestrator hook was causing keyboard unresponsiveness for 10-220 seconds after Claude Code sessions ended. This was most severe for users not running Kitty terminal.
Root cause: The tab-state handler executed
kitten @ set-tab-colorcommands that hung indefinitely when no Kitty socket was available. While Promise.race() timeouts were in place, they only abandoned the promise - the subprocess continued running in the background, blocking terminal I/O until it eventually timed out on its own.Changes:
Add subprocess.ts utility with explicit process control using Bun.spawn() instead of Bun.$``. This enables killing hung processes with SIGTERM followed by SIGKILL fallback after 2 seconds.
Refactor tab-state.ts with terminal detection (matching the existing pattern in UpdateTabTitle.hook.ts). Kitty terminals use remote control API with subprocess timeout protection. Other terminals fall back to escape codes for basic title support.
Apply same terminal detection pattern to SetQuestionTab.hook.ts for consistency across all tab-related hooks.
Add AbortController timeout protection to voice.ts and SystemIntegrity.ts handlers for defense in depth.
The fix provides three layers of protection: