Skip to content

Commit 95bd374

Browse files
authored
Merge branch 'main' into rate-limit-profile-specificv3
2 parents 68f50fa + a15691d commit 95bd374

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+860
-1272
lines changed

scripts/find-missing-translations.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,17 @@ function checkAreaTranslations(area) {
141141
}
142142

143143
// Load file contents
144-
const englishFileContents = englishFiles.map((file) => ({
145-
name: file,
146-
content: JSON.parse(fs.readFileSync(path.join(englishDir, file), "utf8")),
147-
}))
144+
let englishFileContents
145+
146+
try {
147+
englishFileContents = englishFiles.map((file) => ({
148+
name: file,
149+
content: JSON.parse(fs.readFileSync(path.join(englishDir, file), "utf8")),
150+
}))
151+
} catch (e) {
152+
console.error(`Error: File '${englishDir}' is not a valid JSON file`)
153+
process.exit(1)
154+
}
148155

149156
console.log(
150157
`Checking ${englishFileContents.length} translation file(s): ${englishFileContents.map((f) => f.name).join(", ")}`,
@@ -167,7 +174,14 @@ function checkAreaTranslations(area) {
167174
}
168175

169176
// Load the locale file
170-
const localeContent = JSON.parse(fs.readFileSync(localeFilePath, "utf8"))
177+
let localeContent
178+
179+
try {
180+
localeContent = JSON.parse(fs.readFileSync(localeFilePath, "utf8"))
181+
} catch (e) {
182+
console.error(`Error: File '${localeFilePath}' is not a valid JSON file`)
183+
process.exit(1)
184+
}
171185

172186
// Find all keys in the English file
173187
const englishKeys = findKeys(englishContent)

src/core/webview/ClineProvider.ts

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import { BrowserSession } from "../../services/browser/BrowserSession"
4141
import { discoverChromeInstances } from "../../services/browser/browserDiscovery"
4242
import { fileExistsAtPath } from "../../utils/fs"
4343
import { playSound, setSoundEnabled, setSoundVolume } from "../../utils/sound"
44-
import { playTts, setTtsEnabled, setTtsSpeed } from "../../utils/tts"
44+
import { playTts, setTtsEnabled, setTtsSpeed, stopTts } from "../../utils/tts"
4545
import { singleCompletionHandler } from "../../utils/single-completion-handler"
4646
import { searchCommits } from "../../utils/git"
4747
import { getDiffStrategy } from "../diff/DiffStrategy"
@@ -1183,28 +1183,6 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
11831183
}
11841184
break
11851185
}
1186-
case "openProjectMcpSettings": {
1187-
if (!vscode.workspace.workspaceFolders?.length) {
1188-
vscode.window.showErrorMessage(t("common:errors.no_workspace"))
1189-
return
1190-
}
1191-
1192-
const workspaceFolder = vscode.workspace.workspaceFolders[0]
1193-
const rooDir = path.join(workspaceFolder.uri.fsPath, ".roo")
1194-
const mcpPath = path.join(rooDir, "mcp.json")
1195-
1196-
try {
1197-
await fs.mkdir(rooDir, { recursive: true })
1198-
const exists = await fileExistsAtPath(mcpPath)
1199-
if (!exists) {
1200-
await fs.writeFile(mcpPath, JSON.stringify({ mcpServers: {} }, null, 2))
1201-
}
1202-
await openFile(mcpPath)
1203-
} catch (error) {
1204-
vscode.window.showErrorMessage(t("common:errors.create_mcp_json", { error }))
1205-
}
1206-
break
1207-
}
12081186
case "openCustomModesSettings": {
12091187
const customModesFilePath = await this.customModesManager.getCustomModesFilePath()
12101188
if (customModesFilePath) {
@@ -1303,9 +1281,15 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
13031281
break
13041282
case "playTts":
13051283
if (message.text) {
1306-
playTts(message.text)
1284+
playTts(message.text, {
1285+
onStart: () => this.postMessageToWebview({ type: "ttsStart", text: message.text }),
1286+
onStop: () => this.postMessageToWebview({ type: "ttsStop", text: message.text }),
1287+
})
13071288
}
13081289
break
1290+
case "stopTts":
1291+
stopTts()
1292+
break
13091293
case "diffEnabled":
13101294
const diffEnabled = message.bool ?? true
13111295
await this.updateGlobalState("diffEnabled", diffEnabled)

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

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,130 +2055,6 @@ describe("ClineProvider", () => {
20552055
})
20562056
})
20572057

2058-
describe("Project MCP Settings", () => {
2059-
let provider: ClineProvider
2060-
let mockContext: vscode.ExtensionContext
2061-
let mockOutputChannel: vscode.OutputChannel
2062-
let mockWebviewView: vscode.WebviewView
2063-
let mockPostMessage: jest.Mock
2064-
2065-
beforeEach(() => {
2066-
jest.clearAllMocks()
2067-
2068-
mockContext = {
2069-
extensionPath: "/test/path",
2070-
extensionUri: {} as vscode.Uri,
2071-
globalState: {
2072-
get: jest.fn(),
2073-
update: jest.fn(),
2074-
keys: jest.fn().mockReturnValue([]),
2075-
},
2076-
secrets: {
2077-
get: jest.fn(),
2078-
store: jest.fn(),
2079-
delete: jest.fn(),
2080-
},
2081-
subscriptions: [],
2082-
extension: {
2083-
packageJSON: { version: "1.0.0" },
2084-
},
2085-
globalStorageUri: {
2086-
fsPath: "/test/storage/path",
2087-
},
2088-
} as unknown as vscode.ExtensionContext
2089-
2090-
mockOutputChannel = {
2091-
appendLine: jest.fn(),
2092-
clear: jest.fn(),
2093-
dispose: jest.fn(),
2094-
} as unknown as vscode.OutputChannel
2095-
2096-
mockPostMessage = jest.fn()
2097-
mockWebviewView = {
2098-
webview: {
2099-
postMessage: mockPostMessage,
2100-
html: "",
2101-
options: {},
2102-
onDidReceiveMessage: jest.fn(),
2103-
asWebviewUri: jest.fn(),
2104-
},
2105-
visible: true,
2106-
onDidDispose: jest.fn(),
2107-
onDidChangeVisibility: jest.fn(),
2108-
} as unknown as vscode.WebviewView
2109-
2110-
provider = new ClineProvider(mockContext, mockOutputChannel)
2111-
})
2112-
2113-
test("handles openProjectMcpSettings message", async () => {
2114-
await provider.resolveWebviewView(mockWebviewView)
2115-
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as jest.Mock).mock.calls[0][0]
2116-
2117-
// Mock workspace folders
2118-
;(vscode.workspace as any).workspaceFolders = [{ uri: { fsPath: "/test/workspace" } }]
2119-
2120-
// Mock fs functions
2121-
const fs = require("fs/promises")
2122-
fs.mkdir.mockResolvedValue(undefined)
2123-
fs.writeFile.mockResolvedValue(undefined)
2124-
2125-
// Trigger openProjectMcpSettings
2126-
await messageHandler({
2127-
type: "openProjectMcpSettings",
2128-
})
2129-
2130-
// Verify directory was created
2131-
expect(fs.mkdir).toHaveBeenCalledWith(
2132-
expect.stringContaining(".roo"),
2133-
expect.objectContaining({ recursive: true }),
2134-
)
2135-
2136-
// Verify file was created with default content
2137-
expect(fs.writeFile).toHaveBeenCalledWith(
2138-
expect.stringContaining("mcp.json"),
2139-
JSON.stringify({ mcpServers: {} }, null, 2),
2140-
)
2141-
})
2142-
2143-
test("handles openProjectMcpSettings when workspace is not open", async () => {
2144-
await provider.resolveWebviewView(mockWebviewView)
2145-
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as jest.Mock).mock.calls[0][0]
2146-
2147-
// Mock no workspace folders
2148-
;(vscode.workspace as any).workspaceFolders = []
2149-
2150-
// Trigger openProjectMcpSettings
2151-
await messageHandler({
2152-
type: "openProjectMcpSettings",
2153-
})
2154-
2155-
// Verify error message was shown
2156-
expect(vscode.window.showErrorMessage).toHaveBeenCalledWith("Please open a project folder first")
2157-
})
2158-
2159-
test("handles openProjectMcpSettings file creation error", async () => {
2160-
await provider.resolveWebviewView(mockWebviewView)
2161-
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as jest.Mock).mock.calls[0][0]
2162-
2163-
// Mock workspace folders
2164-
;(vscode.workspace as any).workspaceFolders = [{ uri: { fsPath: "/test/workspace" } }]
2165-
2166-
// Mock fs functions to fail
2167-
const fs = require("fs/promises")
2168-
fs.mkdir.mockRejectedValue(new Error("Failed to create directory"))
2169-
2170-
// Trigger openProjectMcpSettings
2171-
await messageHandler({
2172-
type: "openProjectMcpSettings",
2173-
})
2174-
2175-
// Verify error message was shown
2176-
expect(vscode.window.showErrorMessage).toHaveBeenCalledWith(
2177-
expect.stringContaining("Failed to create or open .roo/mcp.json"),
2178-
)
2179-
})
2180-
})
2181-
21822058
describe("ContextProxy integration", () => {
21832059
let provider: ClineProvider
21842060
let mockContext: vscode.ExtensionContext

0 commit comments

Comments
 (0)