@@ -22,7 +22,7 @@ import { Cline } from "../Cline"
2222import { openMention } from "../mentions"
2323import { getNonce } from "./getNonce"
2424import { getUri } from "./getUri"
25- import { playSound , setSoundEnabled } from "../../utils/sound"
25+ import { playSound , setSoundEnabled , setSoundVolume } from "../../utils/sound"
2626
2727/*
2828https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
@@ -66,6 +66,7 @@ type GlobalStateKey =
6666 | "openRouterUseMiddleOutTransform"
6767 | "allowedCommands"
6868 | "soundEnabled"
69+ | "soundVolume"
6970 | "diffEnabled"
7071 | "debugDiffEnabled"
7172 | "alwaysAllowMcp"
@@ -137,6 +138,11 @@ export class ClineProvider implements vscode.WebviewViewProvider {
137138 this . outputChannel . appendLine ( "Resolving webview view" )
138139 this . view = webviewView
139140
141+ // Initialize sound enabled state
142+ this . getState ( ) . then ( ( { soundEnabled } ) => {
143+ setSoundEnabled ( soundEnabled ?? false )
144+ } )
145+
140146 webviewView . webview . options = {
141147 // Allow scripts in the webview
142148 enableScripts : true ,
@@ -597,6 +603,12 @@ export class ClineProvider implements vscode.WebviewViewProvider {
597603 setSoundEnabled ( soundEnabled ) // Add this line to update the sound utility
598604 await this . postStateToWebview ( )
599605 break
606+ case "soundVolume" :
607+ const soundVolume = message . value ?? 0.5
608+ await this . updateGlobalState ( "soundVolume" , soundVolume )
609+ setSoundVolume ( soundVolume )
610+ await this . postStateToWebview ( )
611+ break
600612 case "diffEnabled" :
601613 const diffEnabled = message . bool ?? true
602614 await this . updateGlobalState ( "diffEnabled" , diffEnabled )
@@ -935,6 +947,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
935947 diffEnabled,
936948 debugDiffEnabled,
937949 taskHistory,
950+ soundVolume,
938951 } = await this . getState ( )
939952
940953 const allowedCommands = vscode . workspace
@@ -960,6 +973,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
960973 debugDiffEnabled : debugDiffEnabled ?? false ,
961974 shouldShowAnnouncement : lastShownAnnouncementId !== this . latestAnnouncementId ,
962975 allowedCommands,
976+ soundVolume : soundVolume ?? 0.5 ,
963977 }
964978 }
965979
@@ -1053,6 +1067,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
10531067 soundEnabled ,
10541068 diffEnabled ,
10551069 debugDiffEnabled ,
1070+ soundVolume ,
10561071 ] = await Promise . all ( [
10571072 this . getGlobalState ( "apiProvider" ) as Promise < ApiProvider | undefined > ,
10581073 this . getGlobalState ( "apiModelId" ) as Promise < string | undefined > ,
@@ -1091,6 +1106,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
10911106 this . getGlobalState ( "soundEnabled" ) as Promise < boolean | undefined > ,
10921107 this . getGlobalState ( "diffEnabled" ) as Promise < boolean | undefined > ,
10931108 this . getGlobalState ( "debugDiffEnabled" ) as Promise < boolean | undefined > ,
1109+ this . getGlobalState ( "soundVolume" ) as Promise < number | undefined > ,
10941110 ] )
10951111
10961112 let apiProvider : ApiProvider
@@ -1147,6 +1163,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
11471163 soundEnabled : soundEnabled ?? false ,
11481164 diffEnabled : diffEnabled ?? false ,
11491165 debugDiffEnabled : debugDiffEnabled ?? false ,
1166+ soundVolume,
11501167 }
11511168 }
11521169
0 commit comments