Skip to content

Commit e1ca696

Browse files
committed
Fix tests
1 parent 524bb47 commit e1ca696

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/core/config/__tests__/importExport.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ describe("importExport", () => {
5656
setValues: jest.fn(),
5757
setValue: jest.fn(),
5858
export: jest.fn().mockImplementation(() => Promise.resolve({})),
59+
setProviderSettings: jest.fn(),
5960
} as unknown as jest.Mocked<ContextProxy>
6061

6162
// Setup customModesManager mock

src/core/config/importExport.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { globalSettingsSchema } from "../../schemas"
99
import { ProviderSettingsManager, providerProfilesSchema } from "./ProviderSettingsManager"
1010
import { ContextProxy } from "./ContextProxy"
1111
import { CustomModesManager } from "./CustomModesManager"
12+
import { ProviderSettings } from "../../exports/types"
1213

1314
type ImportOptions = {
1415
providerSettingsManager: ProviderSettingsManager
@@ -38,6 +39,7 @@ export const importSettings = async ({ providerSettingsManager, contextProxy, cu
3839

3940
try {
4041
const previousProviderProfiles = await providerSettingsManager.export()
42+
4143
const { providerProfiles: newProviderProfiles, globalSettings } = schema.parse(
4244
JSON.parse(await fs.readFile(uris[0].fsPath, "utf-8")),
4345
)
@@ -61,12 +63,12 @@ export const importSettings = async ({ providerSettingsManager, contextProxy, cu
6163
await providerSettingsManager.import(newProviderProfiles)
6264
await contextProxy.setValues(globalSettings)
6365

64-
// Roo uses providerSettingsManager to manage api configs, but Cline uses ContextProxy, and to due to some legacy
65-
// code from it, we need to set the the provider setttings here as well.
66-
// For the future we should remove the provider from the proxy and keep providerSettingsManager as source of truth for apiConfig.
67-
const firstApiConfig = Object.values(providerProfiles.apiConfigs)[0]
68-
if (firstApiConfig) {
69-
contextProxy.setProviderSettings(firstApiConfig)
66+
// For the future we should remove the provider from the proxy and keep
67+
// providerSettingsManager as source of truth for apiConfig.
68+
const providerSettings: ProviderSettings = Object.values(providerProfiles.apiConfigs)[0]
69+
70+
if (providerSettings) {
71+
contextProxy.setProviderSettings(providerSettings)
7072
}
7173

7274
contextProxy.setValue("currentApiConfigName", providerProfiles.currentApiConfigName)

0 commit comments

Comments
 (0)