Skip to content

Add notification message storage and waiting session timeout handling#20

Merged
amahpour merged 2 commits intomainfrom
claude/pull-github-issues-7zAVv
Mar 30, 2026
Merged

Add notification message storage and waiting session timeout handling#20
amahpour merged 2 commits intomainfrom
claude/pull-github-issues-7zAVv

Conversation

@amahpour
Copy link
Copy Markdown
Owner

Summary

This PR enhances the notification event handling and adds special timeout logic for sessions in the "waiting" state. Notification messages are now stored in task_description, and waiting sessions receive a longer stale timeout (10 minutes instead of 5 minutes) with prominent logging.

Key Changes

  • Notification message storage: When a Notification event is received with a non-empty message field, it is now stored in the session's task_description. Empty or missing messages do not overwrite existing descriptions.

  • Waiting session timeout handling: Sessions in "waiting" status now use a 10-minute stale timeout instead of the standard 5-minute timeout, allowing more time for operator approval. Non-waiting sessions continue to use the 5-minute threshold.

  • Enhanced logging: When a waiting session times out, a warning is logged with the session ID and elapsed time to help operators identify sessions that have been pending approval for too long.

  • Comprehensive test coverage: Added 15 new tests covering:

    • Notification message storage with various edge cases (empty message, missing field, auto-session creation)
    • Broadcast callback triggering on notification events
    • Full session lifecycle transitions (idle → working → waiting → working → idle)
    • Race conditions (rapid notifications, notification followed by immediate stop)
    • Stale checker behavior for waiting vs. non-waiting sessions
    • Warning log verification for long-waiting sessions

Implementation Details

  • The notification handler checks for a non-empty message field before updating task_description, preventing accidental overwrites.
  • The stale checker now branches on session status: waiting sessions check against a 600-second (10-minute) threshold with warning-level logging, while other statuses use the existing 300-second (5-minute) threshold.
  • All new tests follow existing patterns and use mocking/patching to avoid side effects.

https://claude.ai/code/session_01KdGbmDksNwHqRcCj2TvdAy

- Store notification message in task_description so operators can see
  what Claude is waiting for
- Give waiting sessions a longer stale timeout (10 min vs 5 min) so
  they stay visible longer before being marked stale
- Log a warning when a waiting session finally times out
- Add 13 new tests covering: notification message storage, empty/missing
  message edge cases, auto-session creation, broadcast verification,
  full status lifecycle transitions, rapid notifications, race conditions,
  and waiting-specific stale checker behavior

https://claude.ai/code/session_01KdGbmDksNwHqRcCj2TvdAy
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 30, 2026

Coverage

Unit Test Coverage
FileStmtsMissCoverMissing
__init__.py00100% 
db.py133298%131–132
hooks.py147298%178, 181
main.py370100% 
pr_lookup.py113298%53–54
sessions.py00100% 
terminal.py980100% 
watcher.py3801695%25–28, 337, 528–529, 563–571
routes
   __init__.py00100% 
   api.py1460100% 
   ws.py106892%64–65, 103–104, 106, 125, 141–142
TOTAL11603097% 

Tests Skipped Failures Errors Time
269 0 💤 0 ❌ 0 🔥 16.599s ⏱️

@amahpour amahpour merged commit 5b50220 into main Mar 30, 2026
6 checks passed
@amahpour amahpour deleted the claude/pull-github-issues-7zAVv branch March 30, 2026 04:25
@amahpour amahpour linked an issue Mar 30, 2026 that may be closed by this pull request
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test and harden Notification hook reliability for "waiting" status

2 participants