Revert some whitespace changes

This commit is contained in:
Matt Rubens
2025-01-07 10:25:51 -05:00
parent fe22d1ff2d
commit c9de9cda66
6 changed files with 194 additions and 188 deletions

View File

@@ -235,7 +235,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
diffEnabled,
fuzzyMatchThreshold
} = await this.getState()
this.cline = new Cline(
this,
apiConfiguration,
@@ -255,7 +255,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
diffEnabled,
fuzzyMatchThreshold
} = await this.getState()
this.cline = new Cline(
this,
apiConfiguration,
@@ -321,15 +321,15 @@ export class ClineProvider implements vscode.WebviewViewProvider {
// Use a nonce to only allow a specific script to be run.
/*
content security policy of your webview to only allow scripts that have a specific nonce
create a content security policy meta tag so that only loading scripts with a nonce is allowed
As your extension grows you will likely want to add custom styles, fonts, and/or images to your webview. If you do, you will need to update the content security policy meta tag to explicity allow for these resources. E.g.
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src ${webview.cspSource}; font-src ${webview.cspSource}; img-src ${webview.cspSource} https:; script-src 'nonce-${nonce}';">
content security policy of your webview to only allow scripts that have a specific nonce
create a content security policy meta tag so that only loading scripts with a nonce is allowed
As your extension grows you will likely want to add custom styles, fonts, and/or images to your webview. If you do, you will need to update the content security policy meta tag to explicity allow for these resources. E.g.
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src ${webview.cspSource}; font-src ${webview.cspSource}; img-src ${webview.cspSource} https:; script-src 'nonce-${nonce}';">
- 'unsafe-inline' is required for styles due to vscode-webview-toolkit's dynamic style injection
- since we pass base64 images to the webview, we need to specify img-src ${webview.cspSource} data:;
in meta tag we add nonce attribute: A cryptographic nonce (only used once) to allow scripts. The server must generate a unique nonce value each time it transmits a policy. It is critical to provide a nonce that cannot be guessed as bypassing a resource's policy is otherwise trivial.
*/
in meta tag we add nonce attribute: A cryptographic nonce (only used once) to allow scripts. The server must generate a unique nonce value each time it transmits a policy. It is critical to provide a nonce that cannot be guessed as bypassing a resource's policy is otherwise trivial.
*/
const nonce = getNonce()
// Tip: Install the es6-string-html VS Code extension to enable code highlighting below
@@ -557,7 +557,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
this.postMessageToWebview({ type: "lmStudioModels", lmStudioModels })
break
case "refreshGlamaModels":
await this.refreshGlamaModels()
await this.refreshGlamaModels()
break
case "refreshOpenRouterModels":
await this.refreshOpenRouterModels()
@@ -566,7 +566,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
if (message?.values?.baseUrl && message?.values?.apiKey) {
const openAiModels = await this.getOpenAiModels(message?.values?.baseUrl, message?.values?.apiKey)
this.postMessageToWebview({ type: "openAiModels", openAiModels })
}
}
break
case "openImage":
openImage(message.text!)
@@ -1257,7 +1257,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
alwaysApproveResubmit,
requestDelaySeconds,
} = await this.getState()
const allowedCommands = vscode.workspace
.getConfiguration('roo-cline')
.get<string[]>('allowedCommands') || []

View File

@@ -146,8 +146,8 @@ jest.mock('../../../integrations/misc/extract-text', () => ({
// Spy on console.error and console.log to suppress expected messages
beforeAll(() => {
jest.spyOn(console, 'error').mockImplementation(() => { })
jest.spyOn(console, 'log').mockImplementation(() => { })
jest.spyOn(console, 'error').mockImplementation(() => {})
jest.spyOn(console, 'log').mockImplementation(() => {})
})
afterAll(() => {
@@ -230,7 +230,7 @@ describe('ClineProvider', () => {
test('resolveWebviewView sets up webview correctly', () => {
provider.resolveWebviewView(mockWebviewView)
expect(mockWebviewView.webview.options).toEqual({
enableScripts: true,
localResourceRoots: [mockContext.extensionUri]
@@ -240,7 +240,7 @@ describe('ClineProvider', () => {
test('postMessageToWebview sends message to webview', async () => {
provider.resolveWebviewView(mockWebviewView)
const mockState: ExtensionState = {
version: '1.0.0',
preferredLanguage: 'English',
@@ -263,16 +263,15 @@ describe('ClineProvider', () => {
browserViewportSize: "900x600",
fuzzyMatchThreshold: 1.0,
mcpEnabled: true,
alwaysApproveResubmit: false,
requestDelaySeconds: 5,
requestDelaySeconds: 5
}
const message: ExtensionMessage = {
type: 'state',
const message: ExtensionMessage = {
type: 'state',
state: mockState
}
await provider.postMessageToWebview(message)
expect(mockPostMessage).toHaveBeenCalledWith(message)
})
@@ -303,7 +302,7 @@ describe('ClineProvider', () => {
test('getState returns correct initial state', async () => {
const state = await provider.getState()
expect(state).toHaveProperty('apiConfiguration')
expect(state.apiConfiguration).toHaveProperty('apiProvider')
expect(state).toHaveProperty('customInstructions')
@@ -320,7 +319,7 @@ describe('ClineProvider', () => {
test('preferredLanguage defaults to VSCode language when not set', async () => {
// Mock VSCode language as Spanish
(vscode.env as any).language = 'es-ES';
const state = await provider.getState();
expect(state.preferredLanguage).toBe('Spanish');
})
@@ -328,7 +327,7 @@ describe('ClineProvider', () => {
test('preferredLanguage defaults to English for unsupported VSCode language', async () => {
// Mock VSCode language as an unsupported language
(vscode.env as any).language = 'unsupported-LANG';
const state = await provider.getState();
expect(state.preferredLanguage).toBe('English');
})
@@ -336,9 +335,9 @@ describe('ClineProvider', () => {
test('diffEnabled defaults to true when not set', async () => {
// Mock globalState.get to return undefined for diffEnabled
(mockContext.globalState.get as jest.Mock).mockReturnValue(undefined)
const state = await provider.getState()
expect(state.diffEnabled).toBe(true)
})
@@ -350,7 +349,7 @@ describe('ClineProvider', () => {
}
return null
})
const state = await provider.getState()
expect(state.writeDelayMs).toBe(1000)
})
@@ -358,9 +357,9 @@ describe('ClineProvider', () => {
test('handles writeDelayMs message', async () => {
provider.resolveWebviewView(mockWebviewView)
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as jest.Mock).mock.calls[0][0]
await messageHandler({ type: 'writeDelayMs', value: 2000 })
expect(mockContext.globalState.update).toHaveBeenCalledWith('writeDelayMs', 2000)
expect(mockPostMessage).toHaveBeenCalled()
})