MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / exportSettings

Function exportSettings

src/core/config/importExport.ts:312–351  ·  view source on GitHub ↗
({ providerSettingsManager, contextProxy }: ExportOptions)

Source from the content-addressed store, hash-verified

310}
311
312export const exportSettings = async ({ providerSettingsManager, contextProxy }: ExportOptions) => {
313 const defaultUri = await resolveDefaultSaveUri(contextProxy, "lastSettingsExportPath", "roo-code-settings.json", {
314 useWorkspace: false,
315 fallbackDir: path.join(os.homedir(), "Downloads"),
316 })
317
318 const uri = await vscode.window.showSaveDialog({
319 filters: { JSON: ["json"] },
320 defaultUri,
321 })
322
323 if (!uri) {
324 return
325 }
326
327 await saveLastExportPath(contextProxy, "lastSettingsExportPath", uri)
328
329 try {
330 const providerProfiles = await providerSettingsManager.export()
331 const globalSettings = await contextProxy.export()
332
333 // It's okay if there are no global settings, but if there are no
334 // provider profile configured then don't export. If we wanted to
335 // support this case then the `importSettings` function would need to
336 // be updated to handle the case where there are no provider profiles.
337 if (typeof providerProfiles === "undefined") {
338 return
339 }
340
341 // OpenAI Compatible settings are now correctly stored in codebaseIndexConfig
342 // No workaround needed - they will be exported automatically with the config
343
344 const dirname = path.dirname(uri.fsPath)
345 await fs.mkdir(dirname, { recursive: true })
346 await safeWriteJson(uri.fsPath, { providerProfiles, globalSettings })
347 } catch (e) {
348 console.error("Failed to export settings:", e)
349 // Don't re-throw - the UI will handle showing error messages
350 }
351}
352
353/**
354 * Import settings with complete UI feedback and provider state updates

Callers 2

webviewMessageHandlerFunction · 0.90

Calls 5

resolveDefaultSaveUriFunction · 0.90
saveLastExportPathFunction · 0.90
safeWriteJsonFunction · 0.90
errorMethod · 0.65
exportMethod · 0.45

Tested by

no test coverage detected