From 6f34c95c510f94b92e0f9b49b5c0377f31022a02 Mon Sep 17 00:00:00 2001 From: alexion Date: Tue, 21 Jul 2026 15:23:03 -0400 Subject: [PATCH] fix(claude-code): remove the erroring attention-bell hook The hook rang the terminal bell by walking the process ancestry for a process named `claude`, but nix wraps the binary so its `comm` is `.claude-wrapped`. The match never fired: the bell never rang, and the loop fell through to a non-zero exit that surfaced as a Stop hook error on every turn. Remove the hook, its script, and the Stop and Notification wiring. The tmux monitor-bell config is left in place as a general nicety. --- modules/claude-code/claude-code.nix | 15 --------------- modules/claude-code/hooks/attention-bell.sh | 21 --------------------- 2 files changed, 36 deletions(-) delete mode 100755 modules/claude-code/hooks/attention-bell.sh diff --git a/modules/claude-code/claude-code.nix b/modules/claude-code/claude-code.nix index 9a69ddb..b6221b2 100644 --- a/modules/claude-code/claude-code.nix +++ b/modules/claude-code/claude-code.nix @@ -10,18 +10,6 @@ let cfg = config.modules.claude-code; user = config.user.name; - - # Rings the terminal bell so tmux flags the background pane. - bellHook = [ - { - hooks = [ - { - type = "command"; - command = "~/.claude/hooks/attention-bell.sh"; - } - ]; - } - ]; in { options.modules.claude-code.enable = lib.mkEnableOption '' @@ -57,14 +45,11 @@ in skills = ./skills; # Installed under ~/.claude/hooks, referenced by the settings below. - hooks."attention-bell.sh" = builtins.readFile ./hooks/attention-bell.sh; hooks."agent-sudo-guard.sh" = builtins.readFile ./hooks/agent-sudo-guard.sh; settings = { model = "opus"; hooks = { - Stop = bellHook; - Notification = bellHook; PreToolUse = [ { matcher = "Bash"; diff --git a/modules/claude-code/hooks/attention-bell.sh b/modules/claude-code/hooks/attention-bell.sh deleted file mode 100755 index 0b83487..0000000 --- a/modules/claude-code/hooks/attention-bell.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# attention-bell.sh — ring the terminal bell in this Claude session's tmux pane -# so tmux's monitor-bell flags the (background) window red in the status bar. -# -# Claude Code runs hooks as detached subprocesses: they have no controlling -# terminal, so /dev/tty is unavailable here. But the parent-process chain up to -# the `claude` process stays intact, and `claude` itself holds the pane's pty. -# So we walk ancestry to find it and write the bell straight to that tty. -# (Writing a bare BEL to an explicit /dev/pts/N works even from a detached -# process — verified against tmux's window_bell_flag.) - -pid=$PPID -while [ "$pid" -gt 1 ] 2>/dev/null; do - if [ "$(ps -o comm= -p "$pid" 2>/dev/null)" = claude ]; then - tty=$(ps -o tty= -p "$pid" 2>/dev/null | tr -d ' ') - [ -n "$tty" ] && [ "$tty" != '?' ] && printf '\a' > "/dev/$tty" - exit 0 - fi - pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d ' ') - [ -z "$pid" ] && break -done