Skip to content

Skip version checks for resumed/compacted sessions#166

Merged
nhorton merged 1 commit intomainfrom
claude/skip-non-initial-session-hook-WzeWN
Jan 26, 2026
Merged

Skip version checks for resumed/compacted sessions#166
nhorton merged 1 commit intomainfrom
claude/skip-non-initial-session-hook-WzeWN

Conversation

@nhorton
Copy link
Contributor

@nhorton nhorton commented Jan 26, 2026

Summary

Replace the unreliable environment variable-based re-entry guard with a source-based session detection mechanism. The hook now reads the session source from stdin JSON input to determine whether it's an initial startup or a resumed/compacted session, skipping redundant checks for non-initial sessions.

Key Changes

  • Session source detection: Added logic to parse the source field from hook input JSON (startup, resume, or clear)
  • Skip non-initial sessions: Resume and clear sessions now immediately return empty JSON without running any checks, eliminating redundant version warnings
  • Removed environment variable guard: Replaced the unreliable DEEPWORK_VERSION_CHECK_DONE environment variable approach with the more robust source-based detection
  • Backwards compatibility: Sessions without a source field (older Claude Code versions) are treated as initial sessions to maintain compatibility
  • Comprehensive test coverage: Added 8 new tests covering all session source scenarios, including edge cases

Implementation Details

  • Uses grep and sed for JSON parsing to avoid adding jq as a dependency
  • The source detection happens before the deepwork installation check, so resumed sessions skip all checks efficiently
  • Empty or missing stdin is handled gracefully, defaulting to running the full check for backwards compatibility
  • Unknown future source values are treated conservatively as non-startup sessions

@nhorton nhorton force-pushed the claude/skip-non-initial-session-hook-WzeWN branch from 86cb7d0 to aec6465 Compare January 26, 2026 22:44
The check_version.sh SessionStart hook now reads the JSON input from
stdin and checks the 'source' field to detect non-initial sessions
(resume, clear/compact). These sessions skip all checks immediately
and return empty JSON, reducing noise and avoiding redundant checks.

Initial sessions (source='startup' or missing for backwards compat)
continue to run the full deepwork installation and version checks.

This replaces the previous environment variable-based re-entry guard
which was unreliable across session resumptions.

https://claude.ai/code/session_014fkpR16Pjm2cukh551fiUM
@nhorton nhorton force-pushed the claude/skip-non-initial-session-hook-WzeWN branch from aec6465 to fcf907d Compare January 26, 2026 22:58
@nhorton nhorton merged commit bc97e0c into main Jan 26, 2026
4 checks passed
@nhorton nhorton deleted the claude/skip-non-initial-session-hook-WzeWN branch January 26, 2026 23:04
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.

2 participants