Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
05f8aa2
fix(config): validate the remembered export directory before saving
easonLiangWorldedtech Nov 3, 2026
4888f60
fix(config): keep the export confirmation and the open-dialog default…
easonLiangWorldedtech Nov 3, 2026
0ed9e02
fix(config): check traversal and remember the export location before …
easonLiangWorldedtech Nov 3, 2026
be8c373
fix(config): keep host-local save paths out of imported settings
easonLiangWorldedtech Nov 3, 2026
bcd0822
test(config): assert the silent drop really reports nothing
easonLiangWorldedtech Nov 3, 2026
6536617
fix(config): roll the settings cache back when a state write is rejected
easonLiangWorldedtech Nov 3, 2026
36d0b60
test(config): pin the profile-less export as a no-op
easonLiangWorldedtech Nov 3, 2026
faa9c0b
test(config): type the profile-less export mock so check-types passes
easonLiangWorldedtech Nov 3, 2026
9b089a2
fix(config): keep the settings cache honest across batched same-key w…
easonLiangWorldedtech Nov 3, 2026
8a491fc
test(config): read the cache while the superseded write is still in f…
easonLiangWorldedtech Nov 3, 2026
35a8bf3
fix(config): reconcile the settings cache when same-key writes settle…
easonLiangWorldedtech Nov 3, 2026
ec8850b
fix(config): settle same-key writes against the state they were issue…
easonLiangWorldedtech Nov 3, 2026
4b3d007
fix(config): stop a discarded write from retiring a current one
easonLiangWorldedtech Nov 3, 2026
e265d53
test(config): cover the post-reset rollback the rejected-newer path d…
easonLiangWorldedtech Nov 3, 2026
c61e97b
fix(config): report what landed when the last write standing for a ke…
easonLiangWorldedtech Nov 3, 2026
d241d22
test(config): assert the imported object that actually reaches storage
easonLiangWorldedtech Nov 3, 2026
0411945
Merge upstream/main 73931fe8be25 into fix/export-save-location-stale-…
easonLiangWorldedtech Nov 8, 2026
88df388
fix(export): type host-local keys, cover remembered-over-workspace, a…
easonLiangWorldedtech Nov 11, 2026
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
478 changes: 456 additions & 22 deletions src/core/config/__tests__/importExport.spec.ts

Large diffs are not rendered by default.

60 changes: 55 additions & 5 deletions src/core/config/importExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ function formatZodIssues(error: ZodError): string {
return error.issues.map((issue) => `[${issue.path.join(".") || "value"}]: ${issue.message}`).join(", ")
}

/**
* Save and open dialogs remember an absolute directory per machine, so these
* settings are host-local state rather than configuration. An exported settings
* file must not be able to install another machine's folder layout into this
* one: the dialogs would then probe, and default to, a path nobody picked on
* this machine. They are dropped on import and re-established by the next dialog
* choice.
*/
const hostLocalPathKeyNames = [
"lastSettingsExportPath",
"lastTaskExportPath",
"lastModeExportPath",
"lastImageSavePath",
] as const satisfies readonly (keyof GlobalSettings)[]

const hostLocalPathKeys: ReadonlySet<string> = new Set(hostLocalPathKeyNames)

function sanitizeGlobalSettings(rawGlobalSettings: unknown): {
sanitizedGlobalSettings: GlobalSettings
warnings: string[]
Expand Down Expand Up @@ -105,6 +122,12 @@ function sanitizeGlobalSettings(rawGlobalSettings: unknown): {
continue
}

if (hostLocalPathKeys.has(key)) {
// Deliberately silent: every settings export contains these keys, so warning
// on each import would report nothing the user can act on.
continue
}

let valueToValidate = rawValue

if (key === "imageGenerationProvider" && rawValue === retiredProviderIdentifiers.roo) {
Expand Down Expand Up @@ -270,10 +293,13 @@ export async function importSettingsFromPath(
* @returns Promise resolving to import result
*/
export const importSettings = async ({ providerSettingsManager, contextProxy, customModesManager }: ImportOptions) => {
// Use the last export path as a sensible default, falling back to Downloads
const defaultUri = resolveDefaultSaveUri(contextProxy, "lastSettingsExportPath", "zoo-code-settings.json", {
// Use the last export path as a sensible default, falling back to Downloads.
// An open dialog only reads from that folder, so requiring write access here
// would drop a read-only folder that does hold the settings file.
const defaultUri = await resolveDefaultSaveUri(contextProxy, "lastSettingsExportPath", "zoo-code-settings.json", {
useWorkspace: false,
fallbackDir: path.join(os.homedir(), "Downloads"),
accessMode: fs.constants.R_OK,
})

const uris = await vscode.window.showOpenDialog({
Expand Down Expand Up @@ -327,8 +353,6 @@ export const exportSettings = async ({ providerSettingsManager, contextProxy }:
return
}

await saveLastExportPath(contextProxy, "lastSettingsExportPath", uri)

try {
const providerProfiles = await providerSettingsManager.export()
const globalSettings = await contextProxy.export()
Expand All @@ -348,9 +372,35 @@ export const exportSettings = async ({ providerSettingsManager, contextProxy }:
await fs.mkdir(dirname, { recursive: true })
await safeWriteJson(uri.fsPath, { providerProfiles, globalSettings })
} catch (e) {
const message = e instanceof Error ? e.message : String(e)
console.error("Failed to export settings:", e)
// Don't re-throw - the UI will handle showing error messages
// A silent export failure is how a user ends up with a settings file in a
// folder they never picked: nothing on disk reported that the chosen
// location was unwritable.
await vscode.window.showErrorMessage(t("common:errors.settings_export_failed", { error: message }))
return
}

// Remember only a location that actually received the file, so a failed export
// cannot steer the next dialog either. It runs before the confirmation because
// `showInformationMessage` only resolves once the notification is dismissed, and
// it is guarded because failing to remember a location is not a failed export:
// the export is still reported, just as the partial result it is, and the
// rejection must not escape into the unawaited message handler.
try {
await saveLastExportPath(contextProxy, "lastSettingsExportPath", uri)
} catch (e) {
const reason = e instanceof Error ? e.message : String(e)
console.error("Failed to remember the export location:", e)
// The file was written: report that part plainly, and report the part that
// did not happen instead of pretending the export was complete.
await vscode.window.showWarningMessage(
t("common:warnings.settings_export_location_not_remembered", { path: uri.fsPath, error: reason }),
)
return
}

await vscode.window.showInformationMessage(t("common:info.settings_exported", { path: uri.fsPath }))
}

/**
Expand Down
22 changes: 21 additions & 1 deletion src/i18n/__tests__/locale-bundles.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ import vi from "../locales/vi/common.json"
import zhCn from "../locales/zh-CN/common.json"
import zhTw from "../locales/zh-TW/common.json"

const bundles: Record<string, { errors: Record<string, unknown> }> = {
const bundles: Record<
string,
{ errors: Record<string, unknown>; info: Record<string, unknown>; warnings: Record<string, unknown> }
> = {
ca,
de,
en,
Expand Down Expand Up @@ -58,3 +61,20 @@ describe("common locale bundles", () => {
}
})
})

// Keys the settings-export unit adds to the common namespace: exportSettings
// now names the location that received the file, and names the failure
// instead of swallowing it.
describe("settings export locale bundles", () => {
it.each(Object.keys(bundles))("%s defines every settings export message", (locale) => {
expect(bundles[locale].info.settings_exported).toEqual(expect.any(String))
expect(bundles[locale].info.settings_exported).toContain("{{path}}")
expect(bundles[locale].errors.settings_export_failed).toEqual(expect.any(String))
expect(bundles[locale].errors.settings_export_failed).toContain("{{error}}")
// A written file whose location could not be remembered is a partial export:
// every locale has to be able to say both halves.
expect(bundles[locale].warnings.settings_export_location_not_remembered).toEqual(expect.any(String))
expect(bundles[locale].warnings.settings_export_location_not_remembered).toContain("{{path}}")
expect(bundles[locale].warnings.settings_export_location_not_remembered).toContain("{{error}}")
})
})
3 changes: 3 additions & 0 deletions src/i18n/locales/ca/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/de/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"cannot_access_path": "Cannot access path {{path}}: {{error}}",
"path_outside_workspace": "Path is outside the workspace",
"settings_import_failed": "Settings import failed: {{error}}.",
"settings_export_failed": "Failed to export settings: {{error}}",
"mistake_limit_guidance": "This may indicate a failure in the model's thought process or inability to use a tool properly, which can be mitigated with some user guidance (e.g. \"Try breaking down the task into smaller steps\").",
"violated_organization_allowlist": "Failed to run task: the current profile isn't compatible with your organization settings",
"condense_failed": "Failed to condense context",
Expand Down Expand Up @@ -123,6 +124,7 @@
"warnings": {
"no_terminal_content": "No terminal content selected",
"auto_import_failed": "Failed to auto-import ZooCode settings: {{error}}",
"settings_export_location_not_remembered": "Settings exported to {{path}}, but the location could not be remembered for the next export: {{error}}",
"rooHistoryImport": {
"nothingFound": "No Roo Code task history was found to import from {{domain}}.",
"alreadyImported_one": "All {{count}} Roo Code task history has already been imported into Zoo Code.",
Expand All @@ -134,6 +136,7 @@
"custom_storage_path_set": "Custom storage path set: {{path}}",
"default_storage_path": "Reverted to using default storage path",
"settings_imported": "Settings imported successfully.",
"settings_exported": "Settings exported to {{path}}.",
"auto_import_success": "ZooCode settings automatically imported from {{filename}}",
"image_copied_to_clipboard": "Image data URI copied to clipboard",
"image_saved": "Image saved to {{path}}",
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/locales/es/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/fr/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/hi/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading