mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Play sound effects for notifications and events (#38)
Co-authored-by: HeavenOSK <heavenosk@gmail.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import { Cline } from "../Cline"
|
||||
import { openMention } from "../mentions"
|
||||
import { getNonce } from "./getNonce"
|
||||
import { getUri } from "./getUri"
|
||||
import { playSound, setSoundEnabled } from "../../utils/sound"
|
||||
|
||||
/*
|
||||
https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
|
||||
@@ -61,6 +62,7 @@ type GlobalStateKey =
|
||||
| "openRouterModelId"
|
||||
| "openRouterModelInfo"
|
||||
| "allowedCommands"
|
||||
| "soundEnabled"
|
||||
|
||||
export const GlobalFileNames = {
|
||||
apiConversationHistory: "api_conversation_history.json",
|
||||
@@ -520,6 +522,18 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
break;
|
||||
// Add more switch case statements here as more webview message commands
|
||||
// are created within the webview context (i.e. inside media/main.js)
|
||||
case "playSound":
|
||||
if (message.audioType) {
|
||||
const soundPath = path.join(this.context.extensionPath, "audio", `${message.audioType}.wav`)
|
||||
playSound(soundPath)
|
||||
}
|
||||
break
|
||||
case "soundEnabled":
|
||||
const enabled = message.bool ?? true
|
||||
await this.updateGlobalState("soundEnabled", enabled)
|
||||
setSoundEnabled(enabled)
|
||||
await this.postStateToWebview()
|
||||
break
|
||||
}
|
||||
},
|
||||
null,
|
||||
@@ -825,6 +839,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
alwaysAllowWrite,
|
||||
alwaysAllowExecute,
|
||||
alwaysAllowBrowser,
|
||||
soundEnabled,
|
||||
taskHistory,
|
||||
} = await this.getState()
|
||||
|
||||
@@ -845,6 +860,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
taskHistory: (taskHistory || [])
|
||||
.filter((item) => item.ts && item.task)
|
||||
.sort((a, b) => b.ts - a.ts),
|
||||
soundEnabled: soundEnabled ?? true,
|
||||
shouldShowAnnouncement: lastShownAnnouncementId !== this.latestAnnouncementId,
|
||||
allowedCommands,
|
||||
}
|
||||
@@ -935,6 +951,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
alwaysAllowBrowser,
|
||||
taskHistory,
|
||||
allowedCommands,
|
||||
soundEnabled,
|
||||
] = await Promise.all([
|
||||
this.getGlobalState("apiProvider") as Promise<ApiProvider | undefined>,
|
||||
this.getGlobalState("apiModelId") as Promise<string | undefined>,
|
||||
@@ -968,6 +985,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
this.getGlobalState("alwaysAllowBrowser") as Promise<boolean | undefined>,
|
||||
this.getGlobalState("taskHistory") as Promise<HistoryItem[] | undefined>,
|
||||
this.getGlobalState("allowedCommands") as Promise<string[] | undefined>,
|
||||
this.getGlobalState("soundEnabled") as Promise<boolean | undefined>,
|
||||
])
|
||||
|
||||
let apiProvider: ApiProvider
|
||||
@@ -1019,6 +1037,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
alwaysAllowBrowser: alwaysAllowBrowser ?? false,
|
||||
taskHistory,
|
||||
allowedCommands,
|
||||
soundEnabled,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user