Add configurable duration threshold for notifications#2
Open
Add configurable duration threshold for notifications#2
Conversation
Adds a new `claudeNotifier.durationThreshold` setting (seconds, default 0). When set, the "task completed" sound only plays if Claude worked for at least that many seconds — preventing noisy alerts for quick responses. Permission and question notifications always fire immediately since they require user input regardless of elapsed time. Duration is tracked via a marker file written by mid-task hooks (permission, question) and checked by the stop hook. Fixes #1
added 2 commits
March 1, 2026 09:53
- Threshold now suppresses ALL sounds (completion, permission, question) when Claude has been working for less than the configured duration - PreToolUse hook fires for all tools (not just AskUserQuestion) to reliably record task start time via marker file - Text-only responses (no tool use) produce no sound when threshold > 0 - Force re-registration for users upgrading from matcher-based config
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
Closes #1
Adds a new
claudeNotifier.durationThresholdVS Code setting (number, in seconds, default0). When set to a value > 0, all notification sounds (task completed, permission, and question) are suppressed until Claude has been working for at least that many seconds. If you're still watching the IDE, you don't need audio alerts.How it works
Date.now()timestamp to a marker file (~/.claude/hooks/claude-notifier-taskstart) — only on the first tool call per task (preserves the earliest timestamp)elapsed = now - startTimeelapsed < threshold, the sound and OS notification are skippedCaveat
Duration is measured from the first tool use, not from when the user submits a prompt. This means:
Changes
package.json— newdurationThresholdsetting, version 2.2.0src/extension.ts— syncs threshold to config, cleans up marker file, shows threshold in status bar tooltip, PreToolUse hook fires for all tools (no matcher)hook/claude-notifier-on-stop.js/.ps1— reads marker, checks threshold, cleans uphook/claude-notifier-on-permission.js/.ps1— writes marker, checks threshold before soundhook/claude-notifier-on-question.js/.ps1— writes marker for all tools, checks threshold before sound (only plays sound for AskUserQuestion)README.md— documents the new settingStatus bar
The existing mute toggle addresses the "quick toggle" part of the original request. The tooltip now also shows the configured threshold when > 0.
Test plan
10, ask Claude a quick question (< 10s) → no sound10, give Claude a long task (> 10s) → sound plays0→ all notifications fire as beforenpm run compilepasses with no errors