fix(notify): gracefully handle missing session file (#11)#12
Open
trentmcnitt wants to merge 1 commit into
Open
fix(notify): gracefully handle missing session file (#11)#12trentmcnitt wants to merge 1 commit into
trentmcnitt wants to merge 1 commit into
Conversation
When `cc-notifier notify` fired for a session that had no session file on disk, it crashed with FileNotFoundError and produced a noisy "Command 'notify' failed" error notification on every Stop hook. The user in issue #11 hit this because they installed cc-notifier mid-session — init never ran for that session_id. Changes: - cc_notifier.py: cmd_notify now checks for the session file before reading. When missing, falls through to UNAVAILABLE (same path used when Hammerspoon isn't installed): skips dedup, picks up the current tmux session ID, lets the existing UNAVAILABLE branch decide local notification, and still attempts push. - tests/test_core.py: regression test asserting notify doesn't raise, still hits push, and doesn't log an [ERROR] when the session file is absent. - README.md: spell out the Hammerspoon launch + hs.ipc.cliInstall() step that was missing from the quick-start, with a note that the reload command hanging means this step was skipped. - install.sh: actually exercise `hs -c` with a 5s timeout (via perl alarm — macOS has no portable `timeout` command) instead of only checking that the binary exists, so the install bails early with a clear pointer when Hammerspoon isn't reachable. - Context files updated to reflect new behavior.
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.
Fixes #11.
Summary
cmd_notifyno longer crashes withFileNotFoundErrorwhen the session file is missing. Previously, every Stop hook for a session that had no init file (e.g. cc-notifier was installed mid-session, or Claude Code bug #7911 caused a session-ID mismatch) produced a noisy[ERROR] Command 'notify' failednotification. It now falls through to the existingUNAVAILABLEpath: skips dedup, picks up the current tmux session ID, and still attempts push.hs.ipc.cliInstall()step. The reload command in the quick-start hangs forever if Hammerspoon isn't running or the CLI shim was never installed — issue Getting Error #11 reported exactly this. New troubleshooting note tells the user what to do.hsbinary existed; now actually exerciseshs -c 'print("ok")'with a 5s timeout (viaperl -e 'alarm 5; exec @ARGV'since macOS has no portabletimeoutcommand) and bails with a clear pointer if Hammerspoon isn't reachable. This catches the issue Getting Error #11 setup failure at install time instead of letting it manifest as silent notification errors later.Test plan
make checkpasses (format, lint, typecheck, 72/72 tests, deadcode, shell-lint)test_notify_handles_missing_session_fileasserts notify doesn't raise, still hits push, and doesn't write[ERROR]to the log when the session file is absentperl alarmtimeout trick works on macOS (alarm preserved across exec, exit 142 on timeout)hs -chang during reload/tmp/cc_notifier/$SESSION_IDthen let Claude finish a task) — confirm no[ERROR]notification fires