fix: resolve controlling TTY for hook processes without /dev/tty#51
Open
Rladmsrl wants to merge 1 commit into
Open
fix: resolve controlling TTY for hook processes without /dev/tty#51Rladmsrl wants to merge 1 commit into
Rladmsrl wants to merge 1 commit into
Conversation
Claude Code spawns hook processes without a controlling terminal, so `printf ... > /dev/tty` fails with "Device not configured" (ENXIO) and the OSC notification is silently dropped — Warp never receives the cli-agent event (no notifications, status, or footer ever appear). Add a shared resolve-tty.sh helper that walks up the process tree to an ancestor (the claude process or its parent shell) that still has a controlling tty, and writes the OSC sequence to that device node. Falls back to /dev/tty when no ancestor tty is found, so behavior is unchanged in environments where /dev/tty already works. Applies to both the structured (warp-notify.sh) and legacy (legacy/warp-notify.sh) notification paths.
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
Claude Code spawns hook processes without a controlling terminal. Both
warp-notify.shscripts emit the OSC 777 sequence withprintf … > /dev/tty,which fails in that context — so Warp never receives any cli-agent event
(no notifications, no status, no footer).
Diagnosis
Instrumenting
warp-notify.shto record its runtime context when invoked by areal hook (
UserPromptSubmit/PostToolUse/Stop):should-use-structuredpasses (Warp advertises protocol support), so theplugin intends to send — but the
/dev/ttywrite fails withENXIObecause the hook process is not attached to any controlling terminal, and the
notification is lost.
(The repo is already aware
/dev/ttyisn't always available —tests/test-hooks.shoverrides
/dev/ttywrites "since they'd fail in CI" — but the runtime hookpath was never given the same treatment.)
Fix
New shared helper
scripts/resolve-tty.sh: walk up the process tree from$PPIDto the first ancestor that still has a controlling tty (theclaudeprocess / its parent shell) and write the OSC sequence to that device node.
Falls back to
/dev/ttywhen no ancestor tty is found, so the change isstrictly additive — environments where
/dev/ttyalready works are unaffected.Both
scripts/warp-notify.shandscripts/legacy/warp-notify.shroute through it.Testing
bash -non all three scripts.printfexits 1, nothing reaches theterminal; after — the hook resolves the real PTY (
/dev/ttysNNN), theprintfsucceeds (exit 0), and the terminal receives and parses thecli-agent OSC 777 event.
Claude Code spawns hook processes (no controlling terminal) — independent of
the terminal app — so it should affect current Claude Code generally;
maintainers, please confirm against your environment.