Skip to content

Completion notification (popup + sound) when the window is unfocused#212

Open
leonidasbarkas98-cpu wants to merge 1 commit into
andrepimenta:mainfrom
leonidasbarkas98-cpu:feat/completion-notification
Open

Completion notification (popup + sound) when the window is unfocused#212
leonidasbarkas98-cpu wants to merge 1 commit into
andrepimenta:mainfrom
leonidasbarkas98-cpu:feat/completion-notification

Conversation

@leonidasbarkas98-cpu

Copy link
Copy Markdown

Adds a completion notification for turns that finish while the VS Code window is not focused: a sticky toast (opt-out) and a short completion sound (opt-in). Nothing fires while the window is focused.

Details:

  • New settings claudeCodeChat.notifications.completionPopup (default true) and claudeCodeChat.notifications.completionSound (default false).
  • The toast carries an "Open Chat" action button — an action makes it sticky, otherwise VS Code auto-hides the toast after a few seconds and a notification fired while unfocused would be gone by the time the user switches back.
  • The sound is two short sine tones via the Web Audio API, scheduled against the context's current time only once the context is guaranteed running (tones scheduled against a suspended context's frozen currentTime never audibly play).
  • Browsers only let AudioContext.resume() settle after a user gesture: a one-time warm-up listener (first pointerdown/keydown in the webview) resumes the context early so it is already running when a sound needs to play from an unfocused window; a 2s timeout guards the resume promise.
  • Audio failures never break the webview message handler.

Addresses #92 and #51. Based on current main (ab6e307), tsc --noEmit clean, no new dependencies.

…cused

Adds an opt-out sticky toast and an opt-in completion sound that fire
when a Claude turn finishes while the VS Code window is not focused
(andrepimenta#92, andrepimenta#51). Nothing fires while the window is focused — no point
interrupting someone who is already watching the chat.

- New settings claudeCodeChat.notifications.completionPopup (default
  true) and claudeCodeChat.notifications.completionSound (default
  false).
- The toast carries an 'Open Chat' action button: an action makes it
  sticky (VS Code auto-hides plain toasts after a few seconds, so a
  notification fired while unfocused would be gone by the time the
  user switches back). The action reveals the chat panel.
- The sound is two short sine tones scheduled via the Web Audio API
  against the context's *current* time, only once the context is
  guaranteed running — tones scheduled against a suspended context's
  frozen currentTime never audibly play.
- Browsers only allow AudioContext.resume() to settle after a user
  gesture: a one-time warm-up listener (first pointerdown/keydown in
  the webview) resumes the context early so it is already running by
  the time a sound needs to play from an unfocused window; a 2s
  timeout guards the resume() promise so a never-settling resume
  can't leak state.
- Audio failures never break the webview message handler.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant