feat(hooks): add status-hook.sh for real-time session status tracking#16
Open
MuLinForest wants to merge 2 commits into
Open
feat(hooks): add status-hook.sh for real-time session status tracking#16MuLinForest wants to merge 2 commits into
MuLinForest wants to merge 2 commits into
Conversation
Implement the status-hook slot that was already planned in install.sh
and notify-on-stop.sh but never provided.
- Add hooks/status-hook.sh:
- Writes "<status> <epoch>" to ~/.claude/sessions/<pid>.status
- Supports working (UserPromptSubmit), idle (Stop), waiting (PermissionRequest)
- On "idle", preserves the epoch from the last "working" state so that
notify-on-stop.sh can compute elapsed working time accurately
- Walks up the process tree to find the claude PID (hooks run as direct
children of claude, so this resolves in 1-2 iterations)
- Update hooks/install.sh:
- Install status-hook for UserPromptSubmit, Stop, and PermissionRequest
in the recommended section (before notify-on-stop, which depends on it)
- Step 7 ordering already enforces status-hook first in the Stop array
- Update hooks/README.md and hooks/README.zh-TW.md:
- Add status-hook.sh to quick reference table and layered defaults
- Add detailed section explaining the .status file format and idle
epoch-preservation behavior
Co-Authored-By: Claude Code <claude-core@mulin.date>
PermissionRequest fires on every tool call (including auto-approved ones), so writing "waiting" caused the dashboard to show WAITING throughout the entire working period rather than just when the user is genuinely blocking. Map PermissionRequest to "working" so the status stays WORKING for the full response cycle (thinking + tool execution + reply). WAITING remains available for future use cases that require true user-blocking distinction. Update README docs accordingly. Co-Authored-By: Claude Code <claude-core@mulin.date>
MuLinForest
added a commit
to MuLinForest/claude-code-toolkit
that referenced
this pull request
Mar 26, 2026
…session_title in single jq call Resolve dashboard.sh conflict: add session_title to PR kayhaowu#17's consolidated jq read, removing the redundant individual jq calls from PR kayhaowu#15. Co-Authored-By: Claude Sonnet 4.6 <claude-code@mulin.date>
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.
Summary
Implement the
status-hookslot that was already planned ininstall.sh(Step 7 ordering) and referenced innotify-on-stop.shcomments, but never provided.hooks/status-hook.sh— writes<status> <epoch>to~/.claude/sessions/<pid>.statuson three events:workingon UserPromptSubmitwaitingon PermissionRequestidleon Stop — preserves theworkingepoch sonotify-on-stop.shcan compute elapsed working time accuratelyhooks/install.sh— registers all three hook events in the recommended section, beforenotify-on-stop(which depends on the.statusfile)hooks/README.md+hooks/README.zh-TW.md— document the hook, its.statusfile format, and the idle epoch-preservation behaviorWhy this matters
notify-on-stop.shalready reads~/.claude/sessions/<pid>.statusand expectsidle <working_epoch>format. Withoutstatus-hook.sh, the.statusfile is never written and the elapsed-time calculation innotify-on-stop.shalways fails silently (exits early at the_status_epochcheck).The dashboard (
statusline/dashboard.sh) also reads.statusfiles to show real-time status without polling the session JSON on every render.Test plan
bash hooks/install.shand verify three new hook entries appear in~/.claude/settings.json~/.claude/sessions/<pid>.statuscontainsworking <epoch>idle <working_epoch>waiting <epoch>notify-on-stop.shfires after responses longer than 30 seconds🤖 Generated with Claude Code