fix: TTY detection for hook subprocesses#19
Open
wasikarn wants to merge 1 commit intowarpdotdev:mainfrom
Open
Conversation
bb7de02 to
2b585f2
Compare
Hook subprocesses spawned by Claude Code lack a controlling terminal, making /dev/tty unavailable. This caused OSC 777 notifications to fail silently in some contexts. Changes: - Walk the parent process chain to find the actual TTY device - Add termination check for PID 0/1 to prevent infinite loops - Use [[:space:]] for robust whitespace trimming (spaces + tabs) - Skip notification if TTY not found (don't fall back to broken /dev/tty) - Add tests matching production code exactly - Make tests platform-agnostic (works on macOS /dev/ttysXXX and Linux /dev/pts/N) Tested: Confirmed working with Warp v0.2026.04.08.08.36.stable_05 Note: This fix targets Unix-like systems (macOS, Linux). Windows support would require different TTY detection logic.
2b585f2 to
36e8254
Compare
Author
|
Hi @harryalbert and team, This PR is ready for review. It fixes the TTY detection issue where hook subprocesses fail to send OSC 777 notifications because /dev/tty is unavailable. Key changes:
All 43 tests pass. Tested on Warp v0.2026.04.08.08.36.stable_05. Please review when you have time. Thanks! |
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.
Problem
Hook subprocesses spawned by Claude Code lack a controlling terminal, causing OSC 777 notifications to fail silently.
Root Cause
When Claude Code spawns hook scripts (e.g., on Stop events), the subprocess does not have a controlling terminal. Writing to
/dev/ttyfails with "Device not configured", preventing Warp notifications from being sent.Evidence:
Impact
Solution
Walk the parent process chain to find the actual TTY device that Claude Code is running on.
Changes
[[:space:]]to handle spaces and tabsKey Implementation Details
Testing
Verified Working
Test Coverage
/dev/ttysXXXon macOS and/dev/pts/Non Linux)Manual Verification
Checklist
Platform Notes
Unix-like systems (macOS, Linux): ✅ Fully supported
Windows: Not supported by this fix (requires different TTY detection logic)
cc: @harryalbert (previous contributor)