@@ -12,8 +12,12 @@ function truncateTitle(title: string): string {
1212 return `${ title . slice ( 0 , MAX_TITLE_LENGTH ) } ...` ;
1313}
1414
15- function sendDesktopNotification ( title : string , body : string ) : void {
16- trpcVanilla . notification . send . mutate ( { title, body } ) . catch ( ( err ) => {
15+ function sendDesktopNotification (
16+ title : string ,
17+ body : string ,
18+ silent : boolean ,
19+ ) : void {
20+ trpcVanilla . notification . send . mutate ( { title, body, silent } ) . catch ( ( err ) => {
1721 log . error ( "Failed to send notification" , err ) ;
1822 } ) ;
1923}
@@ -40,26 +44,39 @@ export function notifyPromptComplete(
4044 const isWindowFocused = document . hasFocus ( ) ;
4145 if ( isWindowFocused ) return ;
4246
47+ const willPlayCustomSound = completionSound !== "none" ;
4348 playCompletionSound ( completionSound , completionVolume ) ;
4449
4550 if ( desktopNotifications ) {
46- sendDesktopNotification ( "Twig" , `"${ truncateTitle ( taskTitle ) } " finished` ) ;
51+ sendDesktopNotification (
52+ "Twig" ,
53+ `"${ truncateTitle ( taskTitle ) } " finished` ,
54+ willPlayCustomSound ,
55+ ) ;
4756 }
4857 if ( dockBadgeNotifications ) {
4958 showDockBadge ( ) ;
5059 }
5160}
5261
5362export function notifyPermissionRequest ( taskTitle : string ) : void {
54- const { desktopNotifications, dockBadgeNotifications } =
55- useSettingsStore . getState ( ) ;
63+ const {
64+ completionSound,
65+ completionVolume,
66+ desktopNotifications,
67+ dockBadgeNotifications,
68+ } = useSettingsStore . getState ( ) ;
5669 const isWindowFocused = document . hasFocus ( ) ;
5770
5871 if ( ! isWindowFocused ) {
72+ const willPlayCustomSound = completionSound !== "none" ;
73+ playCompletionSound ( completionSound , completionVolume ) ;
74+
5975 if ( desktopNotifications ) {
6076 sendDesktopNotification (
6177 "Twig" ,
6278 `"${ truncateTitle ( taskTitle ) } " needs your input` ,
79+ willPlayCustomSound ,
6380 ) ;
6481 }
6582 if ( dockBadgeNotifications ) {
0 commit comments