Skip to content

Commit

Permalink
Fix issue where sound effects setting wasn't working
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubens committed Dec 8, 2024
1 parent e180205 commit eb354f0
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Roo Cline Changelog

## [2.1.13]

- Fix https://github.com/RooVetGit/Roo-Cline/issues/50 where sound effects were not respecting settings

## [2.1.12]

- Incorporate JoziGila's [PR](https://github.com/cline/cline/pull/158) to add support for editing through diffs
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Roo Cline",
"description": "A fork of Cline, an autonomous coding agent, with some added experimental configuration and automation features.",
"publisher": "RooVeterinaryInc",
"version": "2.1.12",
"version": "2.1.13",
"icon": "assets/icons/rocket.png",
"galleryBanner": {
"color": "#617A91",
Expand Down
1 change: 1 addition & 0 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
case "soundEnabled":
const soundEnabled = message.bool ?? true
await this.updateGlobalState("soundEnabled", soundEnabled)
setSoundEnabled(soundEnabled) // Add this line to update the sound utility
await this.postStateToWebview()
break
case "diffEnabled":
Expand Down
25 changes: 25 additions & 0 deletions src/core/webview/__tests__/ClineProvider.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ClineProvider } from '../ClineProvider'
import * as vscode from 'vscode'
import { ExtensionMessage, ExtensionState } from '../../../shared/ExtensionMessage'
import { setSoundEnabled } from '../../../utils/sound'

// Mock dependencies
jest.mock('vscode', () => ({
Expand All @@ -25,6 +26,11 @@ jest.mock('vscode', () => ({
}
}))

// Mock sound utility
jest.mock('../../../utils/sound', () => ({
setSoundEnabled: jest.fn()
}))

// Mock ESM modules
jest.mock('p-wait-for', () => ({
__esModule: true,
Expand Down Expand Up @@ -233,4 +239,23 @@ describe('ClineProvider', () => {
expect(state).toHaveProperty('soundEnabled')
expect(state).toHaveProperty('diffEnabled')
})

test('updates sound utility when sound setting changes', async () => {
provider.resolveWebviewView(mockWebviewView)

// Get the message handler from onDidReceiveMessage
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as jest.Mock).mock.calls[0][0]

// Simulate setting sound to enabled
await messageHandler({ type: 'updateSetting', setting: 'soundEnabled', bool: true })
expect(setSoundEnabled).toHaveBeenCalledWith(true)
expect(mockContext.globalState.update).toHaveBeenCalledWith('soundEnabled', true)
expect(mockPostMessage).toHaveBeenCalled()

// Simulate setting sound to disabled
await messageHandler({ type: 'updateSetting', setting: 'soundEnabled', bool: false })
expect(setSoundEnabled).toHaveBeenCalledWith(false)
expect(mockContext.globalState.update).toHaveBeenCalledWith('soundEnabled', false)
expect(mockPostMessage).toHaveBeenCalled()
})
})

0 comments on commit eb354f0

Please sign in to comment.