Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/young-buckets-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"roo-cline": patch
---

Fix global settings export
85 changes: 59 additions & 26 deletions src/core/config/__tests__/importExport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,41 +282,41 @@ describe("importExport", () => {
expect(result.providerProfiles?.apiConfigs["default"]).toBeDefined()
expect(result.providerProfiles?.apiConfigs["default"].apiProvider).toBe("anthropic")
})
})

it("should call updateCustomMode for each custom mode in config", async () => {
;(vscode.window.showOpenDialog as jest.Mock).mockResolvedValue([{ fsPath: "/mock/path/settings.json" }])
it("should call updateCustomMode for each custom mode in config", async () => {
;(vscode.window.showOpenDialog as jest.Mock).mockResolvedValue([{ fsPath: "/mock/path/settings.json" }])

const customModes = [
{ slug: "mode1", name: "Mode One", roleDefinition: "Custom role one", groups: [] },
{ slug: "mode2", name: "Mode Two", roleDefinition: "Custom role two", groups: [] },
]
const customModes = [
{ slug: "mode1", name: "Mode One", roleDefinition: "Custom role one", groups: [] },
{ slug: "mode2", name: "Mode Two", roleDefinition: "Custom role two", groups: [] },
]

const mockFileContent = JSON.stringify({
providerProfiles: { currentApiConfigName: "test", apiConfigs: {} },
globalSettings: { mode: "code", customModes },
})
const mockFileContent = JSON.stringify({
providerProfiles: { currentApiConfigName: "test", apiConfigs: {} },
globalSettings: { mode: "code", customModes },
})

;(fs.readFile as jest.Mock).mockResolvedValue(mockFileContent)
;(fs.readFile as jest.Mock).mockResolvedValue(mockFileContent)

mockProviderSettingsManager.export.mockResolvedValue({
currentApiConfigName: "test",
apiConfigs: {},
})
mockProviderSettingsManager.export.mockResolvedValue({
currentApiConfigName: "test",
apiConfigs: {},
})

mockProviderSettingsManager.listConfig.mockResolvedValue([])
mockProviderSettingsManager.listConfig.mockResolvedValue([])

const result = await importSettings({
providerSettingsManager: mockProviderSettingsManager,
contextProxy: mockContextProxy,
customModesManager: mockCustomModesManager,
})
const result = await importSettings({
providerSettingsManager: mockProviderSettingsManager,
contextProxy: mockContextProxy,
customModesManager: mockCustomModesManager,
})

expect(result.success).toBe(true)
expect(mockCustomModesManager.updateCustomMode).toHaveBeenCalledTimes(customModes.length)
expect(result.success).toBe(true)
expect(mockCustomModesManager.updateCustomMode).toHaveBeenCalledTimes(customModes.length)

customModes.forEach((mode) => {
expect(mockCustomModesManager.updateCustomMode).toHaveBeenCalledWith(mode.slug, mode)
customModes.forEach((mode) => {
expect(mockCustomModesManager.updateCustomMode).toHaveBeenCalledWith(mode.slug, mode)
})
})
})

Expand Down Expand Up @@ -375,6 +375,39 @@ describe("importExport", () => {
)
})

it("should include globalSettings when allowedMaxRequests is null", async () => {
;(vscode.window.showSaveDialog as jest.Mock).mockResolvedValue({
fsPath: "/mock/path/roo-code-settings.json",
})

const mockProviderProfiles = {
currentApiConfigName: "test",
apiConfigs: { test: { apiProvider: "openai" as ProviderName, id: "test-id" } },
migrations: { rateLimitSecondsMigrated: false },
}

mockProviderSettingsManager.export.mockResolvedValue(mockProviderProfiles)

const mockGlobalSettings = {
mode: "code",
autoApprovalEnabled: true,
allowedMaxRequests: null,
}

mockContextProxy.export.mockResolvedValue(mockGlobalSettings)

await exportSettings({
providerSettingsManager: mockProviderSettingsManager,
contextProxy: mockContextProxy,
})

expect(fs.writeFile).toHaveBeenCalledWith(
"/mock/path/roo-code-settings.json",
JSON.stringify({ providerProfiles: mockProviderProfiles, globalSettings: mockGlobalSettings }, null, 2),
"utf-8",
)
})

it("should handle errors during the export process", async () => {
;(vscode.window.showSaveDialog as jest.Mock).mockResolvedValue({
fsPath: "/mock/path/roo-code-settings.json",
Expand Down
4 changes: 2 additions & 2 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
alwaysAllowMcp: alwaysAllowMcp ?? false,
alwaysAllowModeSwitch: alwaysAllowModeSwitch ?? false,
alwaysAllowSubtasks: alwaysAllowSubtasks ?? false,
allowedMaxRequests: allowedMaxRequests ?? Infinity,
allowedMaxRequests,
autoCondenseContextPercent: autoCondenseContextPercent ?? 100,
uriScheme: vscode.env.uriScheme,
currentTaskItem: this.getCurrentCline()?.taskId
Expand Down Expand Up @@ -1369,7 +1369,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
alwaysAllowMcp: stateValues.alwaysAllowMcp ?? false,
alwaysAllowModeSwitch: stateValues.alwaysAllowModeSwitch ?? false,
alwaysAllowSubtasks: stateValues.alwaysAllowSubtasks ?? false,
allowedMaxRequests: stateValues.allowedMaxRequests ?? Infinity,
allowedMaxRequests: stateValues.allowedMaxRequests,
autoCondenseContextPercent: stateValues.autoCondenseContextPercent ?? 100,
taskHistory: stateValues.taskHistory,
allowedCommands: stateValues.allowedCommands,
Expand Down
6 changes: 3 additions & 3 deletions src/exports/roo-code.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type GlobalSettings = {
alwaysAllowSubtasks?: boolean | undefined
alwaysAllowExecute?: boolean | undefined
allowedCommands?: string[] | undefined
allowedMaxRequests?: number | undefined
allowedMaxRequests?: (number | null) | undefined
autoCondenseContextPercent?: number | undefined
browserToolEnabled?: boolean | undefined
browserViewportSize?: string | undefined
Expand Down Expand Up @@ -809,7 +809,7 @@ type IpcMessage =
alwaysAllowSubtasks?: boolean | undefined
alwaysAllowExecute?: boolean | undefined
allowedCommands?: string[] | undefined
allowedMaxRequests?: number | undefined
allowedMaxRequests?: (number | null) | undefined
autoCondenseContextPercent?: number | undefined
browserToolEnabled?: boolean | undefined
browserViewportSize?: string | undefined
Expand Down Expand Up @@ -1286,7 +1286,7 @@ type TaskCommand =
alwaysAllowSubtasks?: boolean | undefined
alwaysAllowExecute?: boolean | undefined
allowedCommands?: string[] | undefined
allowedMaxRequests?: number | undefined
allowedMaxRequests?: (number | null) | undefined
autoCondenseContextPercent?: number | undefined
browserToolEnabled?: boolean | undefined
browserViewportSize?: string | undefined
Expand Down
6 changes: 3 additions & 3 deletions src/exports/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type GlobalSettings = {
alwaysAllowSubtasks?: boolean | undefined
alwaysAllowExecute?: boolean | undefined
allowedCommands?: string[] | undefined
allowedMaxRequests?: number | undefined
allowedMaxRequests?: (number | null) | undefined
autoCondenseContextPercent?: number | undefined
browserToolEnabled?: boolean | undefined
browserViewportSize?: string | undefined
Expand Down Expand Up @@ -823,7 +823,7 @@ type IpcMessage =
alwaysAllowSubtasks?: boolean | undefined
alwaysAllowExecute?: boolean | undefined
allowedCommands?: string[] | undefined
allowedMaxRequests?: number | undefined
allowedMaxRequests?: (number | null) | undefined
autoCondenseContextPercent?: number | undefined
browserToolEnabled?: boolean | undefined
browserViewportSize?: string | undefined
Expand Down Expand Up @@ -1302,7 +1302,7 @@ type TaskCommand =
alwaysAllowSubtasks?: boolean | undefined
alwaysAllowExecute?: boolean | undefined
allowedCommands?: string[] | undefined
allowedMaxRequests?: number | undefined
allowedMaxRequests?: (number | null) | undefined
autoCondenseContextPercent?: number | undefined
browserToolEnabled?: boolean | undefined
browserViewportSize?: string | undefined
Expand Down
2 changes: 1 addition & 1 deletion src/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ export const globalSettingsSchema = z.object({
alwaysAllowSubtasks: z.boolean().optional(),
alwaysAllowExecute: z.boolean().optional(),
allowedCommands: z.array(z.string()).optional(),
allowedMaxRequests: z.number().optional(),
allowedMaxRequests: z.number().nullish(),
autoCondenseContextPercent: z.number().optional(),

browserToolEnabled: z.boolean().optional(),
Expand Down
2 changes: 1 addition & 1 deletion webview-ui/src/components/settings/SettingsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
vscode.postMessage({ type: "alwaysAllowBrowser", bool: alwaysAllowBrowser })
vscode.postMessage({ type: "alwaysAllowMcp", bool: alwaysAllowMcp })
vscode.postMessage({ type: "allowedCommands", commands: allowedCommands ?? [] })
vscode.postMessage({ type: "allowedMaxRequests", value: allowedMaxRequests })
vscode.postMessage({ type: "allowedMaxRequests", value: allowedMaxRequests ?? undefined })
vscode.postMessage({ type: "autoCondenseContextPercent", value: autoCondenseContextPercent })
vscode.postMessage({ type: "browserToolEnabled", bool: browserToolEnabled })
vscode.postMessage({ type: "soundEnabled", bool: soundEnabled })
Expand Down
1 change: 0 additions & 1 deletion webview-ui/src/context/ExtensionStateContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
taskHistory: [],
shouldShowAnnouncement: false,
allowedCommands: [],
allowedMaxRequests: Infinity,
soundEnabled: false,
soundVolume: 0.5,
ttsEnabled: false,
Expand Down