fix(settings): map unknown UI locales to en-US for commit prompts

Portuguese and other interface languages have no commit prompt catalog; sending pt-BR made settings fail to deserialize.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
leokun
2026-09-15 21:31:00 +08:00
co-authored by Cursor
parent c0d5f9a815
commit 127cf8b883
5 changed files with 56 additions and 12 deletions
@@ -1,5 +1,6 @@
import { useCallback, useEffect, useMemo, useState } from "react";
import { api, pluginText, type CommitSettingsView } from "../../shared/api";
import { commitPromptLocale } from "../../i18n/runtime";
import { useI18n } from "../../i18n/store";
import { useAppStore } from "../../shared/store/appStore";
import { Button } from "../../shared/ui/Button";
@@ -33,11 +34,12 @@ export function CommitSettingsCard() {
void (async () => {
try {
let loaded = await api.commitSettings(locale);
if (!loaded.prompt.trim() && loaded.prompt_locale !== locale) {
const promptLocale = commitPromptLocale(locale);
if (!loaded.prompt.trim() && loaded.prompt_locale !== promptLocale) {
loaded = await api.setCommitSettings({
model_id: loaded.model_id,
prompt: "",
prompt_locale: locale,
prompt_locale: promptLocale,
});
}
if (active) {
@@ -97,7 +99,7 @@ export function CommitSettingsCard() {
return api.setCommitSettings({
model_id: modelId,
prompt: normalizedPrompt,
prompt_locale: locale,
prompt_locale: commitPromptLocale(locale),
});
},
[view, locale],
+6
View File
@@ -3,6 +3,12 @@ import enUS from "./locales/en-US.json";
import ptBR from "./locales/pt-BR.json";
export type Locale = "zh-CN" | "en-US" | "pt-BR";
export type CommitPromptLocale = "zh-CN" | "en-US";
export function commitPromptLocale(locale: Locale): CommitPromptLocale {
return locale === "zh-CN" ? "zh-CN" : "en-US";
}
export type TranslationValue = string | number;
export type TranslationParams = Readonly<Record<string, TranslationValue>>;
+2 -2
View File
@@ -1,5 +1,5 @@
import type { AdRuntime } from "../shell/ads/types";
import type { Locale } from "../i18n/runtime";
import type { CommitPromptLocale, Locale } from "../i18n/runtime";
export type ModelType = "openai" | "anthropic";
@@ -154,7 +154,7 @@ export interface DesktopSettings {
export interface CommitSettings {
model_id: string;
prompt: string;
prompt_locale: Locale;
prompt_locale: CommitPromptLocale;
}
export interface CommitSettingsView extends CommitSettings {