Skip to content

Commit 6201c98

Browse files
committed
feat: move play audio to webview to ensure cross-platform
replace sound-play with use-sound for audio handling and add new sound files
1 parent 79d0e50 commit 6201c98

File tree

14 files changed

+78
-119
lines changed

14 files changed

+78
-119
lines changed

package-lock.json

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@
410410
"say": "^0.16.0",
411411
"serialize-error": "^11.0.3",
412412
"simple-git": "^3.27.0",
413-
"sound-play": "^1.1.0",
414413
"string-similarity": "^4.0.4",
415414
"strip-ansi": "^7.1.0",
416415
"strip-bom": "^5.0.0",

src/core/webview/ClineProvider.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import { McpHub } from "../../services/mcp/McpHub"
2929
import { McpServerManager } from "../../services/mcp/McpServerManager"
3030
import { ShadowCheckpointService } from "../../services/checkpoints/ShadowCheckpointService"
3131
import { fileExistsAtPath } from "../../utils/fs"
32-
import { setSoundEnabled } from "../../utils/sound"
3332
import { setTtsEnabled, setTtsSpeed } from "../../utils/tts"
3433
import { ContextProxy } from "../config/ContextProxy"
3534
import { ProviderSettingsManager } from "../config/ProviderSettingsManager"
@@ -327,7 +326,6 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
327326
// Initialize out-of-scope variables that need to recieve persistent global state values
328327
this.getState().then(
329328
({
330-
soundEnabled = false,
331329
terminalShellIntegrationTimeout = Terminal.defaultShellIntegrationTimeout,
332330
terminalShellIntegrationDisabled = false,
333331
terminalCommandDelay = 0,
@@ -337,7 +335,6 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
337335
terminalPowershellCounter = false,
338336
terminalZdotdir = false,
339337
}) => {
340-
setSoundEnabled(soundEnabled)
341338
Terminal.setShellIntegrationTimeout(terminalShellIntegrationTimeout)
342339
Terminal.setShellIntegrationDisabled(terminalShellIntegrationDisabled)
343340
Terminal.setCommandDelay(terminalCommandDelay)

src/core/webview/__tests__/ClineProvider.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import axios from "axios"
66

77
import { ClineProvider } from "../ClineProvider"
88
import { ProviderSettingsEntry, ClineMessage, ExtensionMessage, ExtensionState } from "../../../shared/ExtensionMessage"
9-
import { setSoundEnabled } from "../../../utils/sound"
109
import { setTtsEnabled } from "../../../utils/tts"
1110
import { defaultModeSlug } from "../../../shared/modes"
1211
import { experimentDefault } from "../../../shared/experiments"
@@ -173,9 +172,6 @@ jest.mock("vscode", () => ({
173172
},
174173
}))
175174

176-
jest.mock("../../../utils/sound", () => ({
177-
setSoundEnabled: jest.fn(),
178-
}))
179175

180176
jest.mock("../../../utils/tts", () => ({
181177
setTtsEnabled: jest.fn(),
@@ -545,14 +541,12 @@ describe("ClineProvider", () => {
545541

546542
// Simulate setting sound to enabled
547543
await messageHandler({ type: "soundEnabled", bool: true })
548-
expect(setSoundEnabled).toHaveBeenCalledWith(true)
549544
expect(updateGlobalStateSpy).toHaveBeenCalledWith("soundEnabled", true)
550545
expect(mockContext.globalState.update).toHaveBeenCalledWith("soundEnabled", true)
551546
expect(mockPostMessage).toHaveBeenCalled()
552547

553548
// Simulate setting sound to disabled
554549
await messageHandler({ type: "soundEnabled", bool: false })
555-
expect(setSoundEnabled).toHaveBeenCalledWith(false)
556550
expect(mockContext.globalState.update).toHaveBeenCalledWith("soundEnabled", false)
557551
expect(mockPostMessage).toHaveBeenCalled()
558552

src/core/webview/webviewMessageHandler.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { getTheme } from "../../integrations/theme/getTheme"
1919
import { discoverChromeHostUrl, tryChromeHostUrl } from "../../services/browser/browserDiscovery"
2020
import { searchWorkspaceFiles } from "../../services/search/file-search"
2121
import { fileExistsAtPath } from "../../utils/fs"
22-
import { playSound, setSoundEnabled, setSoundVolume } from "../../utils/sound"
2322
import { playTts, setTtsEnabled, setTtsSpeed, stopTts } from "../../utils/tts"
2423
import { singleCompletionHandler } from "../../utils/single-completion-handler"
2524
import { searchCommits } from "../../utils/git"
@@ -483,22 +482,15 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
483482
await updateGlobalState("enableMcpServerCreation", message.bool ?? true)
484483
await provider.postStateToWebview()
485484
break
486-
case "playSound":
487-
if (message.audioType) {
488-
const soundPath = path.join(provider.context.extensionPath, "audio", `${message.audioType}.wav`)
489-
playSound(soundPath)
490-
}
491-
break
485+
// playSound handler removed - now handled directly in the webview
492486
case "soundEnabled":
493487
const soundEnabled = message.bool ?? true
494488
await updateGlobalState("soundEnabled", soundEnabled)
495-
setSoundEnabled(soundEnabled) // Add this line to update the sound utility
496489
await provider.postStateToWebview()
497490
break
498491
case "soundVolume":
499492
const soundVolume = message.value ?? 0.5
500493
await updateGlobalState("soundVolume", soundVolume)
501-
setSoundVolume(soundVolume)
502494
await provider.postStateToWebview()
503495
break
504496
case "ttsEnabled":

src/utils/sound.ts

Lines changed: 0 additions & 75 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

webview-ui/package-lock.json

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)