🙌 OpenHands: AI-Driven Development
feat(settings): add title generation profile preference (#1910)
simonrosenberg4c5bcdcc1295
diff --git a/__tests__/api/agent-server-adapter.test.ts b/__tests__/api/agent-server-adapter.test.tsindex 89af12beef..ad52b7b804 100644--- a/__tests__/api/agent-server-adapter.test.ts+++ b/__tests__/api/agent-server-adapter.test.ts@@ -64,6 +64,23 @@ beforeEach(() => {});describe("buildStartConversationRequest", () => {+ it("includes the resolved title LLM profile when configured", () => {+ const payload = buildStartConversationRequest({+ settings: DEFAULT_SETTINGS,+ titleLlmProfile: "Titles",+ });++ expect(payload.title_llm_profile).toBe("Titles");+ });++ it("omits the title LLM profile in automatic mode without a default", () => {+ const payload = buildStartConversationRequest({+ settings: DEFAULT_SETTINGS,+ });++ expect(payload).not.toHaveProperty("title_llm_profile");+ });+it("uses nested settings as the source of truth and lets the SDK create the agent", () => {const payload = buildStartConversationRequest({settings: {diff --git a/__tests__/api/agent-server-conversation-service.test.ts b/__tests__/api/agent-server-conversation-service.test.tsindex 66d221c133..911b1429f6 100644--- a/__tests__/api/agent-server-conversation-service.test.ts+++ b/__tests__/api/agent-server-conversation-service.test.ts@@ -31,6 +31,7 @@ const {mockGetSettingsForConversation,mockGetProfile,mockActivateProfile,+ mockListProfiles,} = vi.hoisted(() => ({mockHttpGet: vi.fn(),mockHttpPost: vi.fn(),@@ -44,6 +45,7 @@ const {mockGetSettingsForConversation: vi.fn(),mockGetProfile: vi.fn(),mockActivateProfile: vi.fn(),+ mockListProfiles: vi.fn(),}));const originalFetch = global.fetch;@@ -65,6 +67,7 @@ vi.mock("@openhands/typescript-client/clients", async () => {return {getProfile: mockGetProfile,activateProfile: mockActivateProfile,+ listProfiles: mockListProfiles,};}),SettingsClient: vi.fn(function SettingsClientMock() {@@ -105,6 +108,10 @@ describe("AgentServerConversationService", () => {mockHttpDelete.mockReset();mockGetProfile.mockReset();mockActivateProfile.mockReset();+ mockListProfiles.mockReset().mockResolvedValue({+ profiles: [],+ active_profile: null,+ });mockSwitchProfile.mockReset();mockSwitchLLM.mockReset();fetchMock.mockReset();@@ -243,6 +250,44 @@ describe("AgentServerConversationService", () => {});describe("createConversation", () => {+ it("passes the selected title profile to local conversation starts", async () => {+ mockGetSettings.mockResolvedValue({+ title_llm_profile: "Titles",+ agent_settings: { llm: { model: "gpt-4o" } },+ conversation_settings: {},+ });+ mockGetSettingsForConversation.mockResolvedValue({+ agentSettings: { llm: { model: "gpt-4o" } },+ conversationSettings: {},+ secretsEncrypted: true,+ });+ mockListProfiles.mockResolvedValue({+ profiles: [+ {+ name: "Titles",+ model: "anthropic/claude-haiku-3-5",+ base_url: null,+ api_key_set: true,+ },+ ],+ active_profile: null,+ });+ mockHttpPost.mockResolvedValue({+ data: {+ id: "ignored-server-id",+ created_at: "2024-01-01",+ updated_at: "2024-01-01",+ },+ });++ await AgentServerConversationService.createConversation();++ expect(mockHttpPost).toHaveBeenCalledWith(+ "/api/conversations",+ expect.objectContaining({ title_llm_profile: "Titles" }),+ );+ });+it("generates a unique conversation_id and isolated working_dir per call", async () => {mockGetSettings.mockResolvedValue({agent_settings: { llm: { model: "gpt-4o" } },diff --git a/__tests__/api/settings-service.test.ts b/__tests__/api/settings-service.test.tsindex 4a57c3ffe0..ce8679c3b8 100644--- a/__tests__/api/settings-service.test.ts+++ b/__tests__/api/settings-service.test.ts@@ -172,6 +172,33 @@ describe("SettingsService", () => {]);});+ it("stores the title profile as a local app preference", async () => {+ const patchBodies: Array<Record<string, unknown>> = [];+ server.use(+ http.patch("*/api/settings", async ({ request }) => {+ patchBodies.push((await request.json()) as Record<string, unknown>);+ return HttpResponse.json({+ agent_settings: {},+ conversation_settings: {},+ llm_api_key_is_set: false,+ misc_settings: {+ app_preferences: { title_llm_profile: "Titles" },+ },+ });+ }),+ );++ await SettingsService.saveSettings({ title_llm_profile: "Titles" });++ expect(patchBodies).toEqual([+ {+ misc_settings_diff: {+ app_preferences: { title_llm_profile: "Titles" },+ },+ },+ ]);+ });+it("surfaces server-side misc_settings.app_preferences in getSettings on a local backend", async () => {// The local agent-server returns app_preferences nested under// `misc_settings` on GET /api/settings. The mock handler echoes whatever@@ -183,6 +210,7 @@ describe("SettingsService", () => {git_user_email: "[email protected]",enable_sound_notifications: true,user_consents_to_analytics: true,+ title_llm_profile: "Titles",disabled_skills: ["SSH Microagent"],};await SettingsService.saveSettings(appPrefs);@@ -196,6 +224,7 @@ describe("SettingsService", () => {git_user_email: settings.git_user_email,enable_sound_notifications: settings.enable_sound_notifications,user_consents_to_analytics: settings.user_consents_to_analytics,+ title_llm_profile: settings.title_llm_profile,disabled_skills: settings.disabled_skills,}).toEqual(appPrefs);});@@ -237,12 +266,17 @@ describe("SettingsService", () => {await SettingsService.saveSettings({language: "fr",git_user_name: "Alice",+ title_llm_profile: null,});// Assert: cloud save received the fields under `app_preferences` so// `saveCloudSettings` can spread them into the POST body as flat keys.expect(mockSaveCloudSettings).toHaveBeenCalledWith({- app_preferences: { language: "fr", git_user_name: "Alice" },+ app_preferences: {+ language: "fr",+ git_user_name: "Alice",+ title_llm_profile: null,+ },});});diff --git a/__tests__/components/settings/llm-profiles/rename-profile-modal.test.tsx b/__tests__/components/settings/llm-profiles/rename-profile-modal.test.tsxindex 1234f08a1b..5985b91876 100644--- a/__tests__/components/settings/llm-profiles/rename-profile-modal.test.tsx+++ b/__tests__/components/settings/llm-profiles/rename-profile-modal.test.tsx@@ -152,7 +152,9 @@ describe("RenameProfileModal", () => {);});- expect(handleClose).toHaveBeenCalled();+ await waitFor(() => {+ expect(handleClose).toHaveBeenCalled();+ });});it("disables submit button when name is invalid", async () => {@@ -252,7 +254,9 @@ describe("RenameProfileModal", () => {);});- expect(handleClose).toHaveBeenCalled();+ await waitFor(() => {+ expect(handleClose).toHaveBeenCalled();+ });});it("does not submit form when Enter key is pressed with invalid name", async () => {diff --git a/__tests__/hooks/mutation/use-delete-llm-profile.test.tsx b/__tests__/hooks/mutation/use-delete-llm-profile.test.tsxindex d861ce3b9d..2be1623e08 100644--- a/__tests__/hooks/mutation/use-delete-llm-profile.test.tsx+++ b/__tests__/hooks/mutation/use-delete-llm-profile.test.tsx@@ -5,14 +5,21 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { useDeleteLlmProfile } from "#/hooks/mutation/use-delete-llm-profile";import ProfilesService from "#/api/profiles-service/profiles-service.api";import SettingsService from "#/api/settings-service/settings-service.api";-import { LLM_PROFILES_QUERY_KEYS, SETTINGS_QUERY_KEYS } from "#/hooks/query/query-keys";+import {+ LLM_PROFILES_QUERY_KEYS,+ SETTINGS_QUERY_KEYS,+} from "#/hooks/query/query-keys";vi.mock("#/api/profiles-service/profiles-service.api");vi.mock("#/api/settings-service/settings-service.api");describe("useDeleteLlmProfile", () => {let queryClient: QueryClient;- let wrapper: ({ children }: { children: React.ReactNode }) => React.ReactElement;+ let wrapper: ({+ children,+ }: {+ children: React.ReactNode;+ }) => React.ReactElement;beforeEach(() => {queryClient = new QueryClient({@@ -56,7 +63,14 @@ describe("useDeleteLlmProfile", () => {});queryClient.setQueryData(LLM_PROFILES_QUERY_KEYS.all, {- profiles: [{ name: "deleted-profile", model: "gpt-4", base_url: null, api_key_set: true }],+ profiles: [+ {+ name: "deleted-profile",+ model: "gpt-4",+ base_url: null,+ api_key_set: true,+ },+ ],});const invalidateSpy = vi.spyOn(queryClient, "invalidateQueries");const invalidateCacheSpy = vi.spyOn(SettingsService, "invalidateCache");@@ -77,6 +91,26 @@ describe("useDeleteLlmProfile", () => {});});+ it("clears a deleted local title profile preference", async () => {+ vi.mocked(ProfilesService.deleteProfile).mockResolvedValue({+ name: "Titles",+ message: "Profile deleted",+ });+ vi.mocked(SettingsService.getSettings).mockResolvedValue({+ title_llm_profile: "Titles",+ } as never);++ const { result } = renderHook(() => useDeleteLlmProfile(), { wrapper });++ await act(async () => {+ await result.current.mutateAsync("Titles");+ });++ expect(SettingsService.saveSettings).toHaveBeenCalledWith({+ title_llm_profile: null,+ });+ });+it("handles delete errors", async () => {const error = new Error("Profile not found");vi.mocked(ProfilesService.deleteProfile).mockRejectedValue(error);diff --git a/__tests__/hooks/mutation/use-rename-llm-profile.test.tsx b/__tests__/hooks/mutation/use-rename-llm-profile.test.tsxindex 4b55098af5..cc53d4b853 100644--- a/__tests__/hooks/mutation/use-rename-llm-profile.test.tsx+++ b/__tests__/hooks/mutation/use-rename-llm-profile.test.tsx@@ -5,14 +5,21 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { useRenameLlmProfile } from "#/hooks/mutation/use-rename-llm-profile";import ProfilesService from "#/api/profiles-service/profiles-service.api";import SettingsService from "#/api/settings-service/settings-service.api";-import { LLM_PROFILES_QUERY_KEYS, SETTINGS_QUERY_KEYS } from "#/hooks/query/query-keys";+import {+ LLM_PROFILES_QUERY_KEYS,+ SETTINGS_QUERY_KEYS,+} from "#/hooks/query/query-keys";vi.mock("#/api/profiles-service/profiles-service.api");vi.mock("#/api/settings-service/settings-service.api");describe("useRenameLlmProfile", () => {let queryClient: QueryClient;- let wrapper: ({ children }: { children: React.ReactNode }) => React.ReactElement;+ let wrapper: ({+ children,+ }: {+ children: React.ReactNode;+ }) => React.ReactElement;beforeEach(() => {queryClient = new QueryClient({@@ -49,7 +56,10 @@ describe("useRenameLlmProfile", () => {});});- expect(ProfilesService.renameProfile).toHaveBeenCalledWith("old-name", "new-name");+ expect(ProfilesService.renameProfile).toHaveBeenCalledWith(+ "old-name",+ "new-name",+ );});it("invalidates LLM_PROFILES_QUERY_KEYS.all on success", async () => {@@ -59,7 +69,9 @@ describe("useRenameLlmProfile", () => {});queryClient.setQueryData(LLM_PROFILES_QUERY_KEYS.all, {- profiles: [{ name: "old-name", model: "gpt-4", base_url: null, api_key_set: true }],+ profiles: [+ { name: "old-name", model: "gpt-4", base_url: null, api_key_set: true },+ ],});const invalidateSpy = vi.spyOn(queryClient, "invalidateQueries");@@ -99,6 +111,29 @@ describe("useRenameLlmProfile", () => {});});+ it("renames a selected local title profile preference", async () => {+ vi.mocked(ProfilesService.renameProfile).mockResolvedValue({+ name: "Titles-v2",+ message: "Profile renamed",+ });+ vi.mocked(SettingsService.getSettings).mockResolvedValue({+ title_llm_profile: "Titles",+ } as never);++ const { result } = renderHook(() => useRenameLlmProfile(), { wrapper });++ await act(async () => {+ await result.current.mutateAsync({+ name: "Titles",+ newName: "Titles-v2",+ });+ });++ expect(SettingsService.saveSettings).toHaveBeenCalledWith({+ title_llm_profile: "Titles-v2",+ });+ });+it("handles rename errors (e.g., name conflict)", async () => {const error = new Error("Profile name already exists");vi.mocked(ProfilesService.renameProfile).mockRejectedValue(error);diff --git a/__tests__/routes/app-settings.test.tsx b/__tests__/routes/app-settings.test.tsxindex 8d44e0de21..b698a6a98c 100644--- a/__tests__/routes/app-settings.test.tsx+++ b/__tests__/routes/app-settings.test.tsx@@ -6,6 +6,7 @@ import AppSettingsScreen from "#/routes/app-settings";import SettingsService from "#/api/settings-service/settings-service.api";import { MOCK_DEFAULT_USER_SETTINGS } from "#/mocks/handlers";import { Settings } from "#/types/settings";+import ProfilesService from "#/api/profiles-service/profiles-service.api";function buildSettings(overrides: Partial<Settings> = {}): Settings {return {@@ -26,9 +27,11 @@ function renderAppSettingsScreen() {return render(<AppSettingsScreen />, {wrapper: ({ children }) => (<QueryClientProvider- client={new QueryClient({- defaultOptions: { queries: { retry: false } },- })}+ client={+ new QueryClient({+ defaultOptions: { queries: { retry: false } },+ })+ }>{children}</QueryClientProvider>@@ -60,6 +63,14 @@ describe("AppSettingsScreen", () => {expect(screen.getByTestId("git-user-email-input")).toHaveValue();+ expect(+ screen.getByText("SETTINGS$CONVERSATION_TITLES"),+ ).toBeInTheDocument();+ expect(+ screen.getByRole("combobox", {+ name: "SETTINGS$TITLE_GENERATION_MODEL",+ }),+ ).toHaveValue("SETTINGS$TITLE_GENERATION_AUTOMATIC");});it("saves updated git author details in OSS mode", async () => {@@ -92,4 +103,42 @@ describe("AppSettingsScreen", () => {);});});++ it("saves a dedicated title generation profile", async () => {+ vi.spyOn(ProfilesService, "listProfiles").mockResolvedValue({+ profiles: [+ {+ name: "Titles",+ model: "anthropic/claude-haiku-3-5",+ base_url: null,+ api_key_set: true,+ },+ ],+ active_profile: null,+ });+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(buildSettings());+ const saveSettingsSpy = vi+ .spyOn(SettingsService, "saveSettings")+ .mockResolvedValue(true);++ renderAppSettingsScreen();++ const user = userEvent.setup();+ const input = await screen.findByRole("combobox", {+ name: "SETTINGS$TITLE_GENERATION_MODEL",+ });+ await user.click(input);+ await user.click(+ await screen.findByText("SETTINGS$TITLE_GENERATION_PROFILE_OPTION"),+ );+ await user.click(screen.getByTestId("submit-button"));++ await waitFor(() => {+ expect(saveSettingsSpy).toHaveBeenCalledWith(+ expect.objectContaining({+ title_llm_profile: "Titles",+ }),+ );+ });+ });});diff --git a/__tests__/utils/title-llm-profile.test.ts b/__tests__/utils/title-llm-profile.test.tsnew file mode 100644index 0000000000..5ac90f5f00--- /dev/null+++ b/__tests__/utils/title-llm-profile.test.ts@@ -0,0 +1,43 @@+import { describe, expect, it } from "vitest";+import { resolveTitleLlmProfile } from "#/utils/title-llm-profile";++const profiles = {+ profiles: [+ {+ name: "Default",+ model: "anthropic/claude-sonnet-4",+ base_url: null,+ api_key_set: true,+ },+ {+ name: "Titles",+ model: "anthropic/claude-haiku-3-5",+ base_url: null,+ api_key_set: true,+ },+ ],+ active_profile: "Default",+};++describe("resolveTitleLlmProfile", () => {+ it("uses an available explicit preference", () => {+ expect(resolveTitleLlmProfile("Titles", profiles)).toBe("Titles");+ });++ it("uses the active profile in automatic mode", () => {+ expect(resolveTitleLlmProfile(null, profiles)).toBe("Default");+ });++ it("falls back to the active profile when the preference is stale", () => {+ expect(resolveTitleLlmProfile("Deleted", profiles)).toBe("Default");+ });++ it("omits the value when no profile can be resolved", () => {+ expect(+ resolveTitleLlmProfile(null, {+ profiles: [],+ active_profile: null,+ }),+ ).toBeUndefined();+ });+});diff --git a/scripts/check-translation-completeness.cjs b/scripts/check-translation-completeness.cjsindex 09d5d82bd9..c773d3eac7 100755--- a/scripts/check-translation-completeness.cjs+++ b/scripts/check-translation-completeness.cjs@@ -52,6 +52,7 @@ const IDENTICAL_VALUE_ALLOWLIST = new Set(['SETTINGS$SKILLS_PILLS_MORE','SETTINGS$SKILLS_VERSION','SETTINGS$SLACK',+ 'SETTINGS$TITLE_GENERATION_PROFILE_OPTION','VSCODE$TITLE','WORKSPACE$JUPYTER_TAB_LABEL',]);diff --git a/src/api/agent-server-adapter.ts b/src/api/agent-server-adapter.tsindex 38cb1e15d8..23eae72b12 100644--- a/src/api/agent-server-adapter.ts+++ b/src/api/agent-server-adapter.ts@@ -875,6 +875,7 @@ type StartConversationPayload = Record<string, unknown> & {max_iterations: number;stuck_detection: true;autotitle: true;+ title_llm_profile?: string;worktree: boolean;secrets_encrypted?: true;conversation_id?: string;@@ -900,6 +901,7 @@ export interface StartConversationOptions {// server-side) instead of an inline ``agent_settings`` dump (#3727).agentProfileId?: string;agentProfileKind?: AgentKind;+ titleLlmProfile?: string;}export function buildStartConversationRequest(@@ -962,6 +964,9 @@ export function buildStartConversationRequest(: 500,stuck_detection: true,autotitle: true,+ ...(options.titleLlmProfile+ ? { title_llm_profile: options.titleLlmProfile }+ : {}),worktree: options.worktree ?? true,};@@ -1083,6 +1088,7 @@ export async function buildStartConversationRequestWithEncryptedSettings(optionsworktree?: boolean;agentProfileId?: string;agentProfileKind?: AgentKind;+ titleLlmProfile?: string;}): Promise<Record<string, unknown>> {const { SecretsService } = await import("./secrets-service");diff --git a/src/api/cloud/settings-service.api.ts b/src/api/cloud/settings-service.api.tsindex 612dae676c..d2ba31cc8a 100644--- a/src/api/cloud/settings-service.api.ts+++ b/src/api/cloud/settings-service.api.ts@@ -40,6 +40,7 @@ type CloudSettingsResponse = {email_verified?: boolean;git_user_name?: string;git_user_email?: string;+ title_llm_profile?: string | null;user_consents_to_analytics?: boolean | null;is_new_user?: boolean;remote_runtime_resource_factor?: number | null;diff --git a/src/api/conversation-service/agent-server-conversation-service.api.ts b/src/api/conversation-service/agent-server-conversation-service.api.tsindex 633b37758c..a2ac71fd09 100644--- a/src/api/conversation-service/agent-server-conversation-service.api.ts+++ b/src/api/conversation-service/agent-server-conversation-service.api.ts@@ -56,6 +56,7 @@ import {setStoredConversationMetadata,type WorkspaceMode,} from "../conversation-metadata-store";+import { resolveTitleLlmProfile } from "#/utils/title-llm-profile";import type {GetHooksResponse,PluginSpec,@@ -410,7 +411,14 @@ class AgentServerConversationService {return createCloudAppConversation(request);}- const settings = await SettingsService.getSettings();+ const [settings, profiles] = await Promise.all([+ SettingsService.getSettings(),+ ProfilesService.listProfiles().catch(() => undefined),+ ]);+ const titleLlmProfile = resolveTitleLlmProfile(+ settings.title_llm_profile,+ profiles,+ );const conversationId = uuidv4();// @spec WUP-001 — Send an absolute working_dir to the agent-server.// The default is `workspace/project/<hex>` (relative); without@@ -435,6 +443,7 @@ class AgentServerConversationService {worktree: resolvedWorkspaceMode === "new_worktree",agentProfileId,agentProfileKind,+ titleLlmProfile,});const data = await new ConversationClient(diff --git a/src/api/settings-service/settings-service.api.ts b/src/api/settings-service/settings-service.api.tsindex ec474475c5..719c658a5f 100644--- a/src/api/settings-service/settings-service.api.ts+++ b/src/api/settings-service/settings-service.api.ts@@ -27,6 +27,7 @@ export const APP_PREFERENCE_FIELDS = ["enable_sound_notifications","git_user_name","git_user_email",+ "title_llm_profile","disabled_skills",] as const;diff --git a/src/hooks/mutation/use-delete-llm-profile.ts b/src/hooks/mutation/use-delete-llm-profile.tsindex d4d1094579..fca34b1b04 100644--- a/src/hooks/mutation/use-delete-llm-profile.ts+++ b/src/hooks/mutation/use-delete-llm-profile.ts@@ -5,13 +5,20 @@ import {LLM_PROFILES_QUERY_KEYS,SETTINGS_QUERY_KEYS,} from "#/hooks/query/query-keys";+import { getActiveBackend } from "#/api/backend-registry/active-store";export function useDeleteLlmProfile() {const queryClient = useQueryClient();return useMutation({mutationFn: (name: string) => ProfilesService.deleteProfile(name),- onSuccess: async () => {+ onSuccess: async (_response, name) => {+ if (getActiveBackend().backend.kind === "local") {+ const settings = await SettingsService.getSettings();+ if (settings?.title_llm_profile === name) {+ await SettingsService.saveSettings({ title_llm_profile: null });+ }+ }// Invalidate the SettingsService internal cache so getSettingsForConversation// fetches fresh settings after the profile is deleted (backend may have// deactivated it or reset agent_settings.llm)diff --git a/src/hooks/mutation/use-rename-llm-profile.ts b/src/hooks/mutation/use-rename-llm-profile.tsindex 1a8059fc42..f295f189c7 100644--- a/src/hooks/mutation/use-rename-llm-profile.ts+++ b/src/hooks/mutation/use-rename-llm-profile.ts@@ -5,6 +5,7 @@ import {LLM_PROFILES_QUERY_KEYS,SETTINGS_QUERY_KEYS,} from "#/hooks/query/query-keys";+import { getActiveBackend } from "#/api/backend-registry/active-store";interface RenameLlmProfileVariables {name: string;@@ -17,7 +18,15 @@ export function useRenameLlmProfile() {return useMutation({mutationFn: ({ name, newName }: RenameLlmProfileVariables) =>ProfilesService.renameProfile(name, newName),- onSuccess: async () => {+ onSuccess: async (_response, { name, newName }) => {+ if (getActiveBackend().backend.kind === "local") {+ const settings = await SettingsService.getSettings();+ if (settings?.title_llm_profile === name) {+ await SettingsService.saveSettings({+ title_llm_profile: newName,+ });+ }+ }// Invalidate SettingsService internal cache to ensure fresh settings// (backend references in agent_settings may change when renaming active profile)SettingsService.invalidateCache();diff --git a/src/i18n/translation.json b/src/i18n/translation.jsonindex 55e5482c49..1120335684 100644--- a/src/i18n/translation.json+++ b/src/i18n/translation.json@@ -6629,6 +6629,108 @@"uk": "Профілі LLM","ca": "Perfils LLM"},+ "SETTINGS$CONVERSATION_TITLES": {+ "en": "Conversation titles",+ "ja": "会話タイトル",+ "zh-CN": "对话标题",+ "zh-TW": "對話標題",+ "ko-KR": "대화 제목",+ "de": "Unterhaltungstitel",+ "no": "Samtaletitler",+ "it": "Titoli delle conversazioni",+ "pt": "Títulos das conversas",+ "es": "Títulos de conversaciones",+ "ar": "عناوين المحادثات",+ "fr": "Titres des conversations",+ "tr": "Konuşma başlıkları",+ "uk": "Назви розмов",+ "ca": "Títols de les converses"+ },+ "SETTINGS$TITLE_GENERATION_MODEL": {+ "en": "Title generation model",+ "ja": "タイトル生成モデル",+ "zh-CN": "标题生成模型",+ "zh-TW": "標題產生模型",+ "ko-KR": "제목 생성 모델",+ "de": "Modell für die Titelerstellung",+ "no": "Modell for tittelgenerering",+ "it": "Modello per la generazione dei titoli",+ "pt": "Modelo de geração de títulos",+ "es": "Modelo de generación de títulos",+ "ar": "نموذج إنشاء العناوين",+ "fr": "Modèle de génération des titres",+ "tr": "Başlık oluşturma modeli",+ "uk": "Модель створення назв",+ "ca": "Model de generació de títols"+ },+ "SETTINGS$TITLE_GENERATION_DESCRIPTION": {+ "en": "Choose which LLM profile creates conversation titles. Automatic uses your default LLM profile.",+ "ja": "会話タイトルを生成するLLMプロファイルを選択します。自動ではデフォルトのLLMプロファイルが使用されます。",+ "zh-CN": "选择用于创建对话标题的 LLM 配置文件。自动模式会使用默认的 LLM 配置文件。",+ "zh-TW": "選擇用於建立對話標題的 LLM 設定檔。自動模式會使用預設的 LLM 設定檔。",+ "ko-KR": "대화 제목을 생성할 LLM 프로필을 선택하세요. 자동은 기본 LLM 프로필을 사용합니다.",+ "de": "Wähle das LLM-Profil für Unterhaltungstitel. Automatisch verwendet dein Standard-LLM-Profil.",+ "no": "Velg LLM-profilen som lager samtaletitler. Automatisk bruker standardprofilen din.",+ "it": "Scegli il profilo LLM che crea i titoli delle conversazioni. Automatico usa il profilo LLM predefinito.",+ "pt": "Escolha o perfil LLM que cria os títulos das conversas. Automático usa seu perfil LLM padrão.",+ "es": "Elige el perfil LLM que crea los títulos de las conversaciones. Automático usa tu perfil LLM predeterminado.",+ "ar": "اختر ملف تعريف LLM الذي ينشئ عناوين المحادثات. يستخدم الوضع التلقائي ملف LLM الافتراضي.",+ "fr": "Choisissez le profil LLM qui crée les titres des conversations. Automatique utilise votre profil LLM par défaut.",+ "tr": "Konuşma başlıklarını oluşturan LLM profilini seçin. Otomatik, varsayılan LLM profilinizi kullanır.",+ "uk": "Виберіть профіль LLM для створення назв розмов. Автоматичний режим використовує профіль LLM за замовчуванням.",+ "ca": "Trieu el perfil LLM que crea els títols de les converses. Automàtic utilitza el perfil LLM predeterminat."+ },+ "SETTINGS$TITLE_GENERATION_AUTOMATIC": {+ "en": "Automatic (recommended)",+ "ja": "自動(推奨)",+ "zh-CN": "自动(推荐)",+ "zh-TW": "自動(建議)",+ "ko-KR": "자동(권장)",+ "de": "Automatisch (empfohlen)",+ "no": "Automatisk (anbefalt)",+ "it": "Automatico (consigliato)",+ "pt": "Automático (recomendado)",+ "es": "Automático (recomendado)",+ "ar": "تلقائي (موصى به)",+ "fr": "Automatique (recommandé)",+ "tr": "Otomatik (önerilen)",+ "uk": "Автоматично (рекомендовано)",+ "ca": "Automàtic (recomanat)"+ },+ "SETTINGS$TITLE_GENERATION_PROFILE_OPTION": {+ "en": "{{name}} · {{model}}",+ "ja": "{{name}} · {{model}}",+ "zh-CN": "{{name}} · {{model}}",+ "zh-TW": "{{name}} · {{model}}",+ "ko-KR": "{{name}} · {{model}}",+ "de": "{{name}} · {{model}}",+ "no": "{{name}} · {{model}}",+ "it": "{{name}} · {{model}}",+ "pt": "{{name}} · {{model}}",+ "es": "{{name}} · {{model}}",+ "ar": "{{name}} · {{model}}",+ "fr": "{{name}} · {{model}}",+ "tr": "{{name}} · {{model}}",+ "uk": "{{name}} · {{model}}",+ "ca": "{{name}} · {{model}}"+ },+ "SETTINGS$MANAGE_LLM_PROFILES": {+ "en": "Manage LLM profiles",+ "ja": "LLMプロファイルを管理",+ "zh-CN": "管理 LLM 配置文件",+ "zh-TW": "管理 LLM 設定檔",+ "ko-KR": "LLM 프로필 관리",+ "de": "LLM-Profile verwalten",+ "no": "Administrer LLM-profiler",+ "it": "Gestisci i profili LLM",+ "pt": "Gerenciar perfis LLM",+ "es": "Administrar perfiles LLM",+ "ar": "إدارة ملفات تعريف LLM",+ "fr": "Gérer les profils LLM",+ "tr": "LLM profillerini yönet",+ "uk": "Керувати профілями LLM",+ "ca": "Gestiona els perfils LLM"+ },"SETTINGS$GIT_SETTINGS": {"en": "Git Settings","ja": "Git設定",diff --git a/src/mocks/settings-handlers.ts b/src/mocks/settings-handlers.tsindex 4a6952fe18..afae918b53 100644--- a/src/mocks/settings-handlers.ts+++ b/src/mocks/settings-handlers.ts@@ -954,6 +954,7 @@ export const SETTINGS_HANDLERS = [enable_sound_notifications: null,git_user_name: null,git_user_email: null,+ title_llm_profile: null,disabled_skills: [],};diff --git a/src/routes/app-settings.tsx b/src/routes/app-settings.tsxindex db025f5e11..0dd361410e 100644--- a/src/routes/app-settings.tsx+++ b/src/routes/app-settings.tsx@@ -17,12 +17,19 @@ import {} from "#/utils/custom-toast-handlers";import { retrieveAxiosErrorMessage } from "#/utils/retrieve-axios-error-message";import { AppSettingsInputsSkeleton } from "#/components/features/settings/app-settings/app-settings-inputs-skeleton";+import { SettingsDropdownInput } from "#/components/features/settings/settings-dropdown-input";+import { NavigationLink } from "#/components/shared/navigation-link";+import { useLlmProfiles } from "#/hooks/query/use-llm-profiles";++const AUTOMATIC_TITLE_LLM_PROFILE_KEY = "__automatic__";export function AppSettingsScreen() {const { t } = useTranslation("openhands");const { mutate: saveSettings, isPending } = useSaveSettings();const { data: settings, isLoading } = useSettings();+ const { data: llmProfiles, isLoading: areLlmProfilesLoading } =+ useLlmProfiles();const [languageInputHasChanged, setLanguageInputHasChanged] =React.useState(false);@@ -36,6 +43,39 @@ export function AppSettingsScreen() {React.useState(false);const [gitUserEmailHasChanged, setGitUserEmailHasChanged] =React.useState(false);+ const [titleLlmProfileInput, setTitleLlmProfileInput] = React.useState<+ string | null | undefined+ >(undefined);++ const storedTitleLlmProfile = React.useMemo(() => {+ const preference = settings?.title_llm_profile ?? null;+ if (!preference || !llmProfiles) return preference;+ return llmProfiles.profiles.some((profile) => profile.name === preference)+ ? preference+ : null;+ }, [llmProfiles, settings?.title_llm_profile]);+ const selectedTitleLlmProfile =+ titleLlmProfileInput === undefined+ ? storedTitleLlmProfile+ : titleLlmProfileInput;+ const titleLlmProfileItems = React.useMemo(+ () => [+ {+ key: AUTOMATIC_TITLE_LLM_PROFILE_KEY,+ label: t(I18nKey.SETTINGS$TITLE_GENERATION_AUTOMATIC),+ },+ ...(llmProfiles?.profiles.map((profile) => ({+ key: profile.name,+ label: profile.model+ ? t(I18nKey.SETTINGS$TITLE_GENERATION_PROFILE_OPTION, {+ name: profile.name,+ model: profile.model,+ })+ : profile.name,+ })) ?? []),+ ],+ [llmProfiles?.profiles, t],+ );const formAction = (formData: FormData) => {const languageLabel = formData.get("language-input")?.toString();@@ -63,6 +103,7 @@ export function AppSettingsScreen() {enable_sound_notifications: enableSoundNotifications,git_user_name: gitUserName,git_user_email: gitUserEmail,+ title_llm_profile: selectedTitleLlmProfile,},{onSuccess: () => {@@ -79,6 +120,7 @@ export function AppSettingsScreen() {setSoundNotificationsSwitchHasChanged(false);setGitUserNameHasChanged(false);setGitUserEmailHasChanged(false);+ setTitleLlmProfileInput(undefined);},},);@@ -122,10 +164,12 @@ export function AppSettingsScreen() {!languageInputHasChanged &&!analyticsSwitchHasChanged &&!soundNotificationsSwitchHasChanged &&+ selectedTitleLlmProfile === storedTitleLlmProfile &&!gitUserNameHasChanged &&!gitUserEmailHasChanged;- const shouldBeLoading = !settings || isLoading || isPending;+ const shouldBeLoading =+ !settings || isLoading || areLlmProfilesLoading || isPending;return (<form@@ -162,6 +206,38 @@ export function AppSettingsScreen() {{t(I18nKey.SETTINGS$SOUND_NOTIFICATIONS)}</SettingsSwitch>+ <div className="border-t border-[var(--oh-border)] pt-6 mt-2">+ <h3 className="text-lg font-medium mb-2">+ {t(I18nKey.SETTINGS$CONVERSATION_TITLES)}+ </h3>+ <p className="mb-4 text-sm leading-5 text-tertiary-light">+ {t(I18nKey.SETTINGS$TITLE_GENERATION_DESCRIPTION)}+ </p>+ <SettingsDropdownInput+ testId="title-llm-profile-input"+ name="title-llm-profile-input"+ label={t(I18nKey.SETTINGS$TITLE_GENERATION_MODEL)}+ items={titleLlmProfileItems}+ selectedKey={+ selectedTitleLlmProfile ?? AUTOMATIC_TITLE_LLM_PROFILE_KEY+ }+ onSelectionChange={(key) => {+ const value = key?.toString();+ setTitleLlmProfileInput(+ !value || value === AUTOMATIC_TITLE_LLM_PROFILE_KEY+ ? null+ : value,+ );+ }}+ />+ <NavigationLink+ to="/settings/llm"+ className="mt-3 inline-block text-sm text-primary hover:underline"+ >+ {t(I18nKey.SETTINGS$MANAGE_LLM_PROFILES)}+ </NavigationLink>+ </div>+<div className="border-t border-[var(--oh-border)] pt-6 mt-2"><h3 className="text-lg font-medium mb-2">{t(I18nKey.SETTINGS$GIT_SETTINGS)}diff --git a/src/services/settings.ts b/src/services/settings.tsindex a35effe4f4..4a5329fdd7 100644--- a/src/services/settings.ts+++ b/src/services/settings.ts@@ -34,6 +34,7 @@ export const DEFAULT_SETTINGS: Settings = {email_verified: true,git_user_name: "openhands",git_user_email: "[email protected]",+ title_llm_profile: null,agent_settings_schema: null,agent_settings: {schema_version: 6,diff --git a/src/types/settings.ts b/src/types/settings.tsindex 90f7f66152..9a3a307cc6 100644--- a/src/types/settings.ts+++ b/src/types/settings.ts@@ -166,6 +166,7 @@ export type Settings = {email_verified?: boolean;git_user_name?: string;git_user_email?: string;+ title_llm_profile?: string | null;agent_settings_schema?: SettingsSchema | null;agent_settings?: Record<string, SettingsValue> | null;conversation_settings_schema?: SettingsSchema | null;diff --git a/src/utils/title-llm-profile.ts b/src/utils/title-llm-profile.tsnew file mode 100644index 0000000000..e1cde92fec--- /dev/null+++ b/src/utils/title-llm-profile.ts@@ -0,0 +1,22 @@+import type { ProfileListResponse } from "#/api/profiles-service/profiles-service.api";++export function resolveTitleLlmProfile(+ preference: string | null | undefined,+ profiles: ProfileListResponse | undefined,+): string | undefined {+ if (!profiles) return undefined;++ const availableProfiles = new Set(+ profiles.profiles.map((profile) => profile.name),+ );+ if (preference && availableProfiles.has(preference)) {+ return preference;+ }+ if (+ profiles.active_profile &&+ availableProfiles.has(profiles.active_profile)+ ) {+ return profiles.active_profile;+ }+ return undefined;+}