Skip to content

🙌 OpenHands: AI-Driven Development

fix(i18n): use translation key for subscription models not loaded message (#18308)

Liang Xu76eadf61f68d
diff --git a/__tests__/components/onboarding/setup-llm-step.test.tsx b/__tests__/components/onboarding/setup-llm-step.test.tsx
index 4fb183cbd1..d333e13aef 100644
--- a/__tests__/components/onboarding/setup-llm-step.test.tsx
+++ b/__tests__/components/onboarding/setup-llm-step.test.tsx
@@ -5,6 +5,7 @@ import {
ONBOARDING_DEFAULT_LLM_MODEL,
SetupLlmStep,
} from "#/components/features/onboarding/steps/setup-llm-step";
+import { I18nKey } from "#/i18n/declaration";
import type { SdkSectionSaveControl } from "#/components/features/settings/sdk-settings/sdk-section-page";
import type { SettingsFormValues } from "#/utils/sdk-settings-schema";
import { renderWithProviders } from "../../../test-utils";
@@ -591,7 +592,7 @@ describe("SetupLlmStep", () => {
await waitFor(() =>
expect(displayErrorToast).toHaveBeenCalledWith(
- "Subscription models are not loaded yet.",
+ I18nKey.SETTINGS$SUBSCRIPTION_MODELS_NOT_LOADED,
),
);
expect(saveProfile).not.toHaveBeenCalled();
diff --git a/__tests__/routes/llm-settings.test.tsx b/__tests__/routes/llm-settings.test.tsx
index dbe378d01a..aeaa5583df 100644
--- a/__tests__/routes/llm-settings.test.tsx
+++ b/__tests__/routes/llm-settings.test.tsx
@@ -25,6 +25,7 @@ import ProviderConnectionsService, {
type ProviderConnection,
} from "#/api/provider-connections-service/provider-connections-service.api";
import type { SdkSectionSaveControl } from "#/components/features/settings/sdk-settings/sdk-section-page";
+import { I18nKey } from "#/i18n/declaration";
vi.mock("#/hooks/query/use-llm-profiles");
// The profile manager gates mutate controls on this hook; default to a user
@@ -333,6 +334,46 @@ describe("LlmSettingsScreen", () => {
expect(screen.getByTestId("llm-subscription-model-input")).toBeDisabled();
});
+ it("throws translated error when saving subscription profile before models load", async () => {
+ vi.spyOn(LLMSubscriptionService, "getOpenAIStatus").mockResolvedValue({
+ vendor: "openai",
+ connected: true,
+ accountEmail: "[email protected]",
+ expiresAt: null,
+ });
+ vi.spyOn(LLMSubscriptionService, "getOpenAIModels").mockReturnValue(
+ new Promise(() => {}),
+ );
+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(
+ buildSettings({
+ llm_model: "gpt-5.6-luna",
+ agent_settings: {
+ ...MOCK_DEFAULT_USER_SETTINGS.agent_settings,
+ llm: {
+ model: "gpt-5.6-luna",
+ auth_type: "subscription",
+ subscription_vendor: "openai",
+ },
+ },
+ }),
+ );
+ const saveControlRef: { current: SdkSectionSaveControl | null } = {
+ current: null,
+ };
+
+ renderLlmSettingsScreen({
+ onSaveControlChange: (control) => {
+ saveControlRef.current = control;
+ },
+ });
+
+ await screen.findByTestId("llm-subscription-settings");
+ await waitFor(() => expect(saveControlRef.current).not.toBeNull());
+ expect(() => saveControlRef.current?.getSavePayload()).toThrow(
+ I18nKey.SETTINGS$SUBSCRIPTION_MODELS_NOT_LOADED,
+ );
+ });
+
it("auto-polls the ChatGPT subscription device login after opening verification", async () => {
const openSpy = vi.spyOn(window, "open").mockImplementation(() => null);
vi.spyOn(LLMSubscriptionService, "getOpenAIStatus").mockResolvedValue({
diff --git a/src/components/features/onboarding/steps/setup-llm-step.tsx b/src/components/features/onboarding/steps/setup-llm-step.tsx
index 6f2a8ea1ba..d3d3d3102e 100644
--- a/src/components/features/onboarding/steps/setup-llm-step.tsx
+++ b/src/components/features/onboarding/steps/setup-llm-step.tsx
@@ -280,7 +280,7 @@ export function SetupLlmStep({ onBack, onNext }: SetupLlmStepProps) {
dirtyLlm.model = String(saveControl.values["llm.model"] ?? "");
}
if (isSubscriptionAuth && !subscriptionModels?.length) {
- displayErrorToast("Subscription models are not loaded yet.");
+ displayErrorToast(t(I18nKey.SETTINGS$SUBSCRIPTION_MODELS_NOT_LOADED));
return;
}
const { llmConfig } = buildProfileLlmConfig({
diff --git a/src/i18n/translation.json b/src/i18n/translation.json
index e8f6baf9c9..ab6ec2ab63 100644
--- a/src/i18n/translation.json
+++ b/src/i18n/translation.json
@@ -35019,6 +35019,23 @@
"uk": "Вхід ще не завершено. Завершіть процес у браузері й повторіть спробу.",
"ca": "L’inici de sessió encara no s’ha completat. Acaba el flux del navegador i torna-ho a provar."
},
+ "SETTINGS$SUBSCRIPTION_MODELS_NOT_LOADED": {
+ "en": "Subscription models are not loaded yet.",
+ "ja": "サブスクリプションモデルはまだ読み込まれていません。",
+ "zh-CN": "订阅模型尚未加载。",
+ "zh-TW": "訂閱模型尚未載入。",
+ "ko-KR": "구독 모델이 아직 로드되지 않았습니다.",
+ "no": "Abonnementsmodeller er ikke lastet inn ennå.",
+ "it": "I modelli dell’abbonamento non sono ancora stati caricati.",
+ "pt": "Os modelos de assinatura ainda não foram carregados.",
+ "es": "Los modelos de suscripción aún no se han cargado.",
+ "ar": "لم يتم تحميل نماذج الاشتراك بعد.",
+ "fr": "Les modèles d’abonnement ne sont pas encore chargés.",
+ "tr": "Abonelik modelleri henüz yüklenmedi.",
+ "de": "Abonnementmodelle sind noch nicht geladen.",
+ "uk": "Моделі підписки ще не завантажені.",
+ "ca": "Els models de subscripció encara no s’han carregat."
+ },
"STATUS$VALIDATING": {
"en": "Validating...",
"ja": "検証中...",
diff --git a/src/routes/llm-settings.tsx b/src/routes/llm-settings.tsx
index 90fa1d7306..60dd8eea32 100644
--- a/src/routes/llm-settings.tsx
+++ b/src/routes/llm-settings.tsx
@@ -587,7 +587,7 @@ export function LlmSettingsScreen({
!subscriptionModels?.includes(model) &&
!fallbackSubscriptionModel
) {
- throw new Error("Subscription models are not loaded yet.");
+ throw new Error(t(I18nKey.SETTINGS$SUBSCRIPTION_MODELS_NOT_LOADED));
}
llm.model = subscriptionModels?.includes(model)
? model
@@ -617,7 +617,7 @@ export function LlmSettingsScreen({
agentSettings.llm = llm;
return { agent_settings_diff: agentSettings };
},
- [schema, subscriptionModels, isCloud],
+ [schema, subscriptionModels, isCloud, t],
);
return (