@@ -1284,19 +1284,54 @@ export const webviewMessageHandler = async (
12841284 break
12851285 }
12861286 case "updateSettings" :
1287- if ( message . updatedSettings && typeof message . updatedSettings . mcpEnabled !== "undefined" ) {
1288- const mcpEnabledValue = Boolean ( message . updatedSettings . mcpEnabled )
1289- await updateGlobalState ( "mcpEnabled" , mcpEnabledValue )
1287+ if ( message . updatedSettings ) {
1288+ const s = message . updatedSettings as Record < string , any >
12901289
1291- const mcpHubInstance = provider . getMcpHub ( )
1290+ const setIfDefined = async < K extends keyof GlobalState > ( key : K , value : GlobalState [ K ] | undefined ) => {
1291+ if ( typeof value !== "undefined" ) {
1292+ await updateGlobalState ( key , value as GlobalState [ K ] )
1293+ }
1294+ }
1295+
1296+ // Batch-update supported settings
1297+ await setIfDefined ( "writeDelayMs" , s . writeDelayMs )
1298+ await setIfDefined ( "soundEnabled" , s . soundEnabled )
1299+
1300+ if ( typeof s . ttsEnabled !== "undefined" ) {
1301+ const v = ! ! s . ttsEnabled
1302+ await updateGlobalState ( "ttsEnabled" , v )
1303+ setTtsEnabled ( v )
1304+ }
1305+ if ( typeof s . ttsSpeed === "number" ) {
1306+ await updateGlobalState ( "ttsSpeed" , s . ttsSpeed )
1307+ setTtsSpeed ( s . ttsSpeed )
1308+ }
1309+
1310+ await setIfDefined ( "autoCondenseContext" , s . autoCondenseContext )
1311+ await setIfDefined ( "autoCondenseContextPercent" , s . autoCondenseContextPercent )
1312+ await setIfDefined ( "browserToolEnabled" , s . browserToolEnabled )
1313+ await setIfDefined ( "showRooIgnoredFiles" , s . showRooIgnoredFiles )
1314+ await setIfDefined ( "alwaysApproveResubmit" , s . alwaysApproveResubmit )
1315+ await setIfDefined ( "requestDelaySeconds" , s . requestDelaySeconds )
12921316
1293- if ( mcpHubInstance ) {
1294- await mcpHubInstance . handleMcpEnabledChange ( mcpEnabledValue )
1317+ if ( typeof s . maxWorkspaceFiles === "number" ) {
1318+ const fileCount = Math . min ( Math . max ( 0 , s . maxWorkspaceFiles ) , 500 )
1319+ await updateGlobalState ( "maxWorkspaceFiles" , fileCount )
1320+ }
1321+
1322+ // MCP enabled/disabled
1323+ if ( typeof s . mcpEnabled !== "undefined" ) {
1324+ const mcpEnabledValue = ! ! s . mcpEnabled
1325+ await updateGlobalState ( "mcpEnabled" , mcpEnabledValue )
1326+ const mcpHubInstance = provider . getMcpHub ( )
1327+ if ( mcpHubInstance ) {
1328+ await mcpHubInstance . handleMcpEnabledChange ( mcpEnabledValue )
1329+ }
12951330 }
12961331
12971332 await provider . postStateToWebview ( )
12981333 } else {
1299- // No recognized settings provided; refresh state to keep UI in sync
1334+ // No settings provided; refresh to keep UI in sync
13001335 await provider . postStateToWebview ( )
13011336 }
13021337 break
0 commit comments