fix: improve state detection accuracy and notification UX

- Hook reads JSON from stdin (not env vars) matching Claude Code protocol
- end_turn = Idle (not NeedsInput); real questions come from hooks
- Permission prompt (stale tool_use) never becomes Idle
- Notifications auto-expire after 10s (--expire-time)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Pierre Martin
2026-03-24 11:29:26 +01:00
parent 0e4ced5b1f
commit 001c453462
5 changed files with 41 additions and 23 deletions

View File

@@ -7,15 +7,11 @@ import (
"path/filepath"
)
// parseHookEnv builds a HookEvent from Claude Code hook environment variables.
func parseHookEnv() HookEvent {
return HookEvent{
SessionID: os.Getenv("SESSION_ID"),
Cwd: os.Getenv("SESSION_CWD"),
HookEventName: os.Getenv("HOOK_EVENT_NAME"),
NotificationType: os.Getenv("NOTIFICATION_TYPE"),
ToolName: os.Getenv("TOOL_NAME"),
}
// parseHookStdin reads a HookEvent from stdin (Claude Code sends JSON on stdin).
func parseHookStdin() HookEvent {
var event HookEvent
json.NewDecoder(os.Stdin).Decode(&event)
return event
}
// runSetup adds vmux hooks to ~/.claude/settings.json (idempotent).