fix(hooks): prevent terminal I/O blocking from hung Kitty subprocesses#473
Open
ozten wants to merge 1 commit intodanielmiessler:mainfrom
Open
fix(hooks): prevent terminal I/O blocking from hung Kitty subprocesses#473ozten wants to merge 1 commit intodanielmiessler:mainfrom
ozten wants to merge 1 commit intodanielmiessler:mainfrom
Conversation
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-color` commands 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: 1. Terminal detection - skip Kitty-specific code entirely for non-Kitty 2. Escape code fallback - basic functionality for all terminals 3. Subprocess control - kill hung processes after 2s timeout (Kitty) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Author
|
I don't think this PR fixes the garbled screen issue, but it does eliminate the unresponsiveness that reproduced 100% of the time when using PAI without Kitty. |
Author
|
Please restart the checks. This one failed because |
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.
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: