🙌 OpenHands: AI-Driven Development
feat: LLM profiles UI components, modals, and tests (PR B) (#389)
Rohit Malhotra8fc9a8b50c7c
diff --git a/__tests__/components/settings/llm-profiles/delete-profile-modal.test.tsx b/__tests__/components/settings/llm-profiles/delete-profile-modal.test.tsxnew file mode 100644index 0000000000..153bc8ee9b--- /dev/null+++ b/__tests__/components/settings/llm-profiles/delete-profile-modal.test.tsx@@ -0,0 +1,204 @@+import { render, screen, waitFor } from "@testing-library/react";+import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";+import userEvent from "@testing-library/user-event";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { DeleteProfileModal } from "#/components/features/settings/llm-profiles/delete-profile-modal";+import { ProfileInfo } from "#/api/profiles-service/profiles-service.api";+import ProfilesService from "#/api/profiles-service/profiles-service.api";+import * as toastHandlers from "#/utils/custom-toast-handlers";++vi.mock("react-i18next", () => ({+ useTranslation: () => ({+ t: (key: string, params?: Record<string, string>) => {+ const translations: Record<string, string> = {+ "SETTINGS$PROFILE_DELETE_TITLE": "Delete Profile",+ "SETTINGS$PROFILE_DELETE_CONFIRMATION": params?.name+ ? `Are you sure you want to delete "${params.name}"?`+ : "Are you sure you want to delete this profile?",+ "SETTINGS$PROFILE_DELETED": params?.name+ ? `Profile "${params.name}" deleted`+ : "Profile deleted",+ "BUTTON$DELETE": "Delete",+ "BUTTON$CANCEL": "Cancel",+ "ERROR$GENERIC": "An error occurred",+ };+ return translations[key] || key;+ },+ }),+}));++vi.mock("#/api/profiles-service/profiles-service.api");+vi.mock("#/utils/custom-toast-handlers");++const mockProfile: ProfileInfo = {+ name: "profile-to-delete",+ model: "openai/gpt-4",+ base_url: null,+ api_key_set: true,+};++describe("DeleteProfileModal", () => {+ let queryClient: QueryClient;++ const renderModal = (+ profile: ProfileInfo | null,+ onClose = vi.fn(),+ ) => {+ return render(+ <QueryClientProvider client={queryClient}>+ <DeleteProfileModal profile={profile} onClose={onClose} />+ </QueryClientProvider>,+ );+ };++ beforeEach(() => {+ queryClient = new QueryClient({+ defaultOptions: {+ queries: { retry: false },+ mutations: { retry: false },+ },+ });+ });++ afterEach(() => {+ queryClient.clear();+ vi.clearAllMocks();+ });++ it("returns null when profile is null", () => {+ const { container } = renderModal(null);+ expect(container.firstChild).toBeNull();+ });++ it("renders the modal with confirmation message", () => {+ renderModal(mockProfile);+ expect(+ screen.getByText('Are you sure you want to delete "profile-to-delete"?'),+ ).toBeInTheDocument();+ });++ it("shows Delete and Cancel buttons", () => {+ renderModal(mockProfile);+ expect(screen.getByTestId("delete-profile-confirm")).toHaveTextContent(+ "Delete",+ );+ expect(screen.getByText("Cancel")).toBeInTheDocument();+ });++ it("calls onClose when Cancel is clicked", async () => {+ const user = userEvent.setup();+ const handleClose = vi.fn();+ renderModal(mockProfile, handleClose);++ await user.click(screen.getByText("Cancel"));++ expect(handleClose).toHaveBeenCalledTimes(1);+ expect(ProfilesService.deleteProfile).not.toHaveBeenCalled();+ });++ it("calls deleteProfile and shows success toast on successful delete", async () => {+ const user = userEvent.setup();+ const handleClose = vi.fn();+ vi.mocked(ProfilesService.deleteProfile).mockResolvedValue({+ name: "profile-to-delete",+ message: "Profile deleted",+ });++ renderModal(mockProfile, handleClose);++ await user.click(screen.getByTestId("delete-profile-confirm"));++ await waitFor(() => {+ expect(ProfilesService.deleteProfile).toHaveBeenCalledWith(+ "profile-to-delete",+ );+ });++ expect(toastHandlers.displaySuccessToast).toHaveBeenCalledWith(+ 'Profile "profile-to-delete" deleted',+ );+ expect(handleClose).toHaveBeenCalled();+ });++ it("shows error toast on delete failure", async () => {+ const user = userEvent.setup();+ const handleClose = vi.fn();+ vi.mocked(ProfilesService.deleteProfile).mockRejectedValue(+ new Error("Delete failed"),+ );++ renderModal(mockProfile, handleClose);++ await user.click(screen.getByTestId("delete-profile-confirm"));++ await waitFor(() => {+ expect(toastHandlers.displayErrorToast).toHaveBeenCalledWith(+ "Delete failed",+ );+ });++ expect(handleClose).not.toHaveBeenCalled();+ });++ it("shows generic error message for non-Error exceptions", async () => {+ const user = userEvent.setup();+ vi.mocked(ProfilesService.deleteProfile).mockRejectedValue("Unknown error");++ renderModal(mockProfile);++ await user.click(screen.getByTestId("delete-profile-confirm"));++ await waitFor(() => {+ expect(toastHandlers.displayErrorToast).toHaveBeenCalledWith(+ "An error occurred",+ );+ });+ });++ it("delete button has danger variant styling", () => {+ renderModal(mockProfile);+ const deleteButton = screen.getByTestId("delete-profile-confirm");+ // The BrandButton with variant="danger" should be rendered+ expect(deleteButton).toBeInTheDocument();+ });++ describe("isPending state", () => {+ it("prevents closing modal during deletion", async () => {+ const user = userEvent.setup();+ vi.mocked(ProfilesService.deleteProfile).mockImplementation(+ () => new Promise(() => {}), // Never resolves+ );+ const handleClose = vi.fn();+ renderModal(mockProfile, handleClose);++ await user.click(screen.getByTestId("delete-profile-confirm"));+ await user.click(screen.getByText("Cancel"));++ expect(handleClose).not.toHaveBeenCalled();+ });++ it("disables Cancel button during deletion", async () => {+ const user = userEvent.setup();+ vi.mocked(ProfilesService.deleteProfile).mockImplementation(+ () => new Promise(() => {}), // Never resolves+ );+ renderModal(mockProfile);++ await user.click(screen.getByTestId("delete-profile-confirm"));++ expect(screen.getByText("Cancel")).toBeDisabled();+ });++ it("disables Delete button during deletion", async () => {+ const user = userEvent.setup();+ vi.mocked(ProfilesService.deleteProfile).mockImplementation(+ () => new Promise(() => {}), // Never resolves+ );+ renderModal(mockProfile);++ await user.click(screen.getByTestId("delete-profile-confirm"));++ expect(screen.getByTestId("delete-profile-confirm")).toBeDisabled();+ });+ });+});diff --git a/__tests__/components/settings/llm-profiles/llm-profiles-manager.test.tsx b/__tests__/components/settings/llm-profiles/llm-profiles-manager.test.tsxnew file mode 100644index 0000000000..c1e73ad45e--- /dev/null+++ b/__tests__/components/settings/llm-profiles/llm-profiles-manager.test.tsx@@ -0,0 +1,291 @@+import { render, screen } from "@testing-library/react";+import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";+import userEvent from "@testing-library/user-event";+import React from "react";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { LlmProfilesManager } from "#/components/features/settings/llm-profiles/llm-profiles-manager";+import ProfilesService, {+ ProfileInfo,+} from "#/api/profiles-service/profiles-service.api";++vi.mock("react-i18next", () => ({+ useTranslation: () => ({+ t: (key: string, params?: Record<string, string>) => {+ const translations: Record<string, string> = {+ "SETTINGS$AVAILABLE_PROFILES": "Available LLM Profiles",+ "SETTINGS$ADD_LLM_PROFILE": "Add LLM Profile",+ "SETTINGS$PROFILES_LOAD_ERROR": "Failed to load profiles",+ "SETTINGS$PROFILES_EMPTY": "No profiles saved yet",+ "SETTINGS$PROFILE_ACTIVE": "Active",+ "SETTINGS$PROFILE_MENU": "Profile menu",+ "SETTINGS$PROFILE_EDIT": "Edit",+ "SETTINGS$PROFILE_SET_ACTIVE": "Set as active",+ "SETTINGS$PROFILE_RENAME_TITLE": "Rename Profile",+ "SETTINGS$PROFILE_DELETE_TITLE": "Delete Profile",+ "SETTINGS$PROFILE_DELETE_CONFIRMATION": params?.name+ ? `Are you sure you want to delete "${params.name}"?`+ : "Are you sure you want to delete this profile?",+ "SETTINGS$PROFILE_ACTIVATED": params?.name+ ? `Profile "${params.name}" activated`+ : "Profile activated",+ "SETTINGS$PROFILE_NAME_LABEL": "Profile Name",+ "SETTINGS$PROFILE_NAME_PLACEHOLDER": "Enter profile name",+ "SETTINGS$PROFILE_NAME_RULE":+ "1-64 chars, start with alphanumeric, then alphanumerics or . _ -",+ "BUTTON$RENAME": "Rename",+ "BUTTON$DELETE": "Delete",+ "BUTTON$CANCEL": "Cancel",+ "ERROR$GENERIC": "An error occurred",+ };+ return translations[key] || key;+ },+ }),+}));++vi.mock("#/api/profiles-service/profiles-service.api");+vi.mock("#/utils/custom-toast-handlers");++const mockProfiles: ProfileInfo[] = [+ {+ name: "gpt-4-profile",+ model: "openai/gpt-4",+ base_url: null,+ api_key_set: true,+ },+ {+ name: "claude-profile",+ model: "anthropic/claude-3",+ base_url: "https://api.anthropic.com",+ api_key_set: false,+ },+];++describe("LlmProfilesManager", () => {+ let queryClient: QueryClient;++ const renderManager = (props: {+ onAddProfile?: () => void;+ onEditProfile?: (profile: ProfileInfo) => void;+ } = {}) => {+ return render(+ <QueryClientProvider client={queryClient}>+ <LlmProfilesManager {...props} />+ </QueryClientProvider>,+ );+ };++ beforeEach(() => {+ queryClient = new QueryClient({+ defaultOptions: {+ queries: { retry: false },+ mutations: { retry: false },+ },+ });+ });++ afterEach(() => {+ queryClient.clear();+ vi.clearAllMocks();+ });++ it("displays the section title", async () => {+ vi.mocked(ProfilesService.listProfiles).mockResolvedValue({+ profiles: mockProfiles, active_profile: "gpt-4-profile",+ });++ renderManager();++ expect(screen.getByText("Available LLM Profiles")).toBeInTheDocument();+ });++ it("shows Add LLM Profile button when onAddProfile is provided", async () => {+ vi.mocked(ProfilesService.listProfiles).mockResolvedValue({+ profiles: [], active_profile: null,+ });++ renderManager({ onAddProfile: vi.fn() });++ expect(screen.getByTestId("add-llm-profile")).toBeInTheDocument();+ expect(screen.getByText("Add LLM Profile")).toBeInTheDocument();+ });++ it("does not show Add LLM Profile button when onAddProfile is not provided", async () => {+ vi.mocked(ProfilesService.listProfiles).mockResolvedValue({+ profiles: [], active_profile: null,+ });++ renderManager();++ expect(screen.queryByTestId("add-llm-profile")).not.toBeInTheDocument();+ });++ it("calls onAddProfile when Add LLM Profile is clicked", async () => {+ const user = userEvent.setup();+ const handleAddProfile = vi.fn();+ vi.mocked(ProfilesService.listProfiles).mockResolvedValue({+ profiles: [], active_profile: null,+ });++ renderManager({ onAddProfile: handleAddProfile });++ await user.click(screen.getByTestId("add-llm-profile"));++ expect(handleAddProfile).toHaveBeenCalledTimes(1);+ });++ it("displays profiles when they exist", async () => {+ vi.mocked(ProfilesService.listProfiles).mockResolvedValue({+ profiles: mockProfiles, active_profile: "gpt-4-profile",+ });++ renderManager();++ await screen.findByText("gpt-4-profile");+ expect(screen.getByText("claude-profile")).toBeInTheDocument();+ });++ it("shows empty state when no profiles exist", async () => {+ vi.mocked(ProfilesService.listProfiles).mockResolvedValue({+ profiles: [], active_profile: null,+ });++ renderManager();++ await screen.findByText("No profiles saved yet");+ });++ it("shows loading spinner while loading", () => {+ // Mock a never-resolving promise to keep loading state+ vi.mocked(ProfilesService.listProfiles).mockImplementation(+ () => new Promise(() => {}),+ );++ renderManager();++ expect(screen.getByTestId("loading-spinner")).toBeInTheDocument();+ });++ it("shows error message when loading fails", async () => {+ vi.mocked(ProfilesService.listProfiles).mockRejectedValue(+ new Error("Network error"),+ );++ renderManager();++ await screen.findByText("Failed to load profiles");+ });++ it("calls onEditProfile when Edit is clicked from profile menu", async () => {+ const user = userEvent.setup();+ const handleEditProfile = vi.fn();+ vi.mocked(ProfilesService.listProfiles).mockResolvedValue({+ profiles: mockProfiles, active_profile: "gpt-4-profile",+ });++ renderManager({ onEditProfile: handleEditProfile });++ // Wait for profiles to load+ await screen.findByText("gpt-4-profile");++ // Click the first profile's menu trigger+ const menuTriggers = screen.getAllByTestId("profile-menu-trigger");+ await user.click(menuTriggers[0]);++ // Click Edit+ await user.click(screen.getByText("Edit"));++ expect(handleEditProfile).toHaveBeenCalledWith(mockProfiles[0]);+ });++ it("opens rename modal when Rename is clicked from profile menu", async () => {+ const user = userEvent.setup();+ vi.mocked(ProfilesService.listProfiles).mockResolvedValue({+ profiles: mockProfiles, active_profile: "gpt-4-profile",+ });++ renderManager();++ await screen.findByText("gpt-4-profile");++ const menuTriggers = screen.getAllByTestId("profile-menu-trigger");+ await user.click(menuTriggers[0]);+ await user.click(screen.getByText("Rename"));++ // Rename modal should appear with input pre-filled+ expect(screen.getByTestId("rename-profile-input")).toHaveValue(+ "gpt-4-profile",+ );+ });++ it("opens delete modal when Delete is clicked from profile menu", async () => {+ const user = userEvent.setup();+ vi.mocked(ProfilesService.listProfiles).mockResolvedValue({+ profiles: mockProfiles, active_profile: "gpt-4-profile",+ });++ renderManager();++ await screen.findByText("gpt-4-profile");++ const menuTriggers = screen.getAllByTestId("profile-menu-trigger");+ await user.click(menuTriggers[0]);+ await user.click(screen.getByText("Delete"));++ // Delete modal should appear with confirmation message+ expect(+ screen.getByText('Are you sure you want to delete "gpt-4-profile"?'),+ ).toBeInTheDocument();+ });++ it("closes rename modal when onClose is called", async () => {+ const user = userEvent.setup();+ vi.mocked(ProfilesService.listProfiles).mockResolvedValue({+ profiles: mockProfiles, active_profile: "gpt-4-profile",+ });++ renderManager();++ await screen.findByText("gpt-4-profile");++ // Open rename modal+ const menuTriggers = screen.getAllByTestId("profile-menu-trigger");+ await user.click(menuTriggers[0]);+ await user.click(screen.getByText("Rename"));++ expect(screen.getByTestId("rename-profile-input")).toBeInTheDocument();++ // Click Cancel+ await user.click(screen.getByText("Cancel"));++ // Modal should be closed+ expect(screen.queryByTestId("rename-profile-input")).not.toBeInTheDocument();+ });++ it("closes delete modal when onClose is called", async () => {+ const user = userEvent.setup();+ vi.mocked(ProfilesService.listProfiles).mockResolvedValue({+ profiles: mockProfiles, active_profile: "gpt-4-profile",+ });++ renderManager();++ await screen.findByText("gpt-4-profile");++ // Open delete modal+ const menuTriggers = screen.getAllByTestId("profile-menu-trigger");+ await user.click(menuTriggers[0]);+ await user.click(screen.getByText("Delete"));++ expect(+ screen.getByText('Are you sure you want to delete "gpt-4-profile"?'),+ ).toBeInTheDocument();++ // Click Cancel+ await user.click(screen.getByText("Cancel"));++ // Modal should be closed+ expect(+ screen.queryByText('Are you sure you want to delete "gpt-4-profile"?'),+ ).not.toBeInTheDocument();+ });+});diff --git a/__tests__/components/settings/llm-profiles/profile-actions-menu.test.tsx b/__tests__/components/settings/llm-profiles/profile-actions-menu.test.tsxnew file mode 100644index 0000000000..0919e8a00b--- /dev/null+++ b/__tests__/components/settings/llm-profiles/profile-actions-menu.test.tsx@@ -0,0 +1,251 @@+import { render, screen, fireEvent } from "@testing-library/react";+import { describe, expect, it, vi } from "vitest";+import userEvent from "@testing-library/user-event";+import { ProfileActionsMenu } from "#/components/features/settings/llm-profiles/profile-actions-menu";++vi.mock("react-i18next", () => ({+ useTranslation: () => ({+ t: (key: string) => {+ const translations: Record<string, string> = {+ "SETTINGS$PROFILE_EDIT": "Edit",+ "BUTTON$RENAME": "Rename",+ "SETTINGS$PROFILE_SET_ACTIVE": "Set as active",+ "BUTTON$DELETE": "Delete",+ };+ return translations[key] || key;+ },+ }),+}));++const defaultProps = {+ onEdit: vi.fn(),+ onRename: vi.fn(),+ onSetActive: vi.fn(),+ onDelete: vi.fn(),+ isActive: false,+ isActivating: false,+ onClose: vi.fn(),+};++describe("ProfileActionsMenu", () => {+ it("renders Edit, Rename, Set Active, and Delete buttons", () => {+ render(<ProfileActionsMenu {...defaultProps} />);++ expect(screen.getByTestId("profile-edit")).toHaveTextContent("Edit");+ expect(screen.getByTestId("profile-rename")).toHaveTextContent("Rename");+ expect(screen.getByTestId("profile-set-active")).toHaveTextContent("Set as active");+ expect(screen.getByTestId("profile-delete")).toHaveTextContent("Delete");+ });++ it("calls onEdit and onClose when Edit is clicked", async () => {+ const user = userEvent.setup();+ const handleEdit = vi.fn();+ const handleClose = vi.fn();++ render(+ <ProfileActionsMenu+ {...defaultProps}+ onEdit={handleEdit}+ onClose={handleClose}+ />,+ );++ await user.click(screen.getByTestId("profile-edit"));++ expect(handleEdit).toHaveBeenCalledTimes(1);+ expect(handleClose).toHaveBeenCalledTimes(1);+ });++ it("calls onRename and onClose when Rename is clicked", async () => {+ const user = userEvent.setup();+ const handleRename = vi.fn();+ const handleClose = vi.fn();++ render(+ <ProfileActionsMenu+ {...defaultProps}+ onRename={handleRename}+ onClose={handleClose}+ />,+ );++ await user.click(screen.getByTestId("profile-rename"));++ expect(handleRename).toHaveBeenCalledTimes(1);+ expect(handleClose).toHaveBeenCalledTimes(1);+ });++ it("calls onSetActive and onClose when Set Active is clicked", async () => {+ const user = userEvent.setup();+ const handleSetActive = vi.fn();+ const handleClose = vi.fn();++ render(+ <ProfileActionsMenu+ {...defaultProps}+ onSetActive={handleSetActive}+ onClose={handleClose}+ />,+ );++ await user.click(screen.getByTestId("profile-set-active"));++ expect(handleSetActive).toHaveBeenCalledTimes(1);+ expect(handleClose).toHaveBeenCalledTimes(1);+ });++ it("disables Set Active when already active", () => {+ render(<ProfileActionsMenu {...defaultProps} isActive />);++ const setActiveButton = screen.getByTestId("profile-set-active");+ expect(setActiveButton).toBeDisabled();+ });++ it("disables Set Active when activating", () => {+ render(<ProfileActionsMenu {...defaultProps} isActivating />);++ const setActiveButton = screen.getByTestId("profile-set-active");+ expect(setActiveButton).toBeDisabled();+ });++ it("calls onDelete and onClose when Delete is clicked", async () => {+ const user = userEvent.setup();+ const handleDelete = vi.fn();+ const handleClose = vi.fn();++ render(+ <ProfileActionsMenu+ {...defaultProps}+ onDelete={handleDelete}+ onClose={handleClose}+ />,+ );++ await user.click(screen.getByTestId("profile-delete"));++ expect(handleDelete).toHaveBeenCalledTimes(1);+ expect(handleClose).toHaveBeenCalledTimes(1);+ });++ it("calls onClose when clicking outside the menu", () => {+ const handleClose = vi.fn();++ render(+ <div>+ <div data-testid="outside">Outside</div>+ <ProfileActionsMenu {...defaultProps} onClose={handleClose} />+ </div>,+ );++ fireEvent.mouseDown(screen.getByTestId("outside"));++ expect(handleClose).toHaveBeenCalledTimes(1);+ });++ it("calls onClose when Escape key is pressed", () => {+ const handleClose = vi.fn();++ render(<ProfileActionsMenu {...defaultProps} onClose={handleClose} />);++ fireEvent.keyDown(document, { key: "Escape" });++ expect(handleClose).toHaveBeenCalledTimes(1);+ });++ it("does not call onClose for other keys", () => {+ const handleClose = vi.fn();++ render(<ProfileActionsMenu {...defaultProps} onClose={handleClose} />);++ fireEvent.keyDown(document, { key: "Enter" });+ fireEvent.keyDown(document, { key: "ArrowDown" });++ expect(handleClose).not.toHaveBeenCalled();+ });++ it("has correct accessibility attributes", () => {+ render(<ProfileActionsMenu {...defaultProps} />);++ const menu = screen.getByRole("menu");+ expect(menu).toHaveAttribute("aria-orientation", "vertical");++ const menuItems = screen.getAllByRole("menuitem");+ expect(menuItems).toHaveLength(4);+ });++ it("Delete button has red text styling", () => {+ render(<ProfileActionsMenu {...defaultProps} />);++ const deleteButton = screen.getByTestId("profile-delete");+ expect(deleteButton).toHaveClass("text-red-400");+ });++ it("does not call onClose when clicking inside the menu container", () => {+ const handleClose = vi.fn();++ render(<ProfileActionsMenu {...defaultProps} onClose={handleClose} />);++ const menu = screen.getByRole("menu");+ fireEvent.mouseDown(menu);++ expect(handleClose).not.toHaveBeenCalled();+ });++ describe("keyboard navigation", () => {+ it("focuses first item on mount", () => {+ render(<ProfileActionsMenu {...defaultProps} />);+ expect(screen.getByTestId("profile-edit")).toHaveFocus();+ });++ it("navigates down with ArrowDown key", async () => {+ const user = userEvent.setup();+ render(<ProfileActionsMenu {...defaultProps} />);++ await user.keyboard("{ArrowDown}");+ expect(screen.getByTestId("profile-rename")).toHaveFocus();+ });++ it("navigates up with ArrowUp key", async () => {+ const user = userEvent.setup();+ render(<ProfileActionsMenu {...defaultProps} />);++ // Start at first item (Edit), go down to Rename, then back up+ await user.keyboard("{ArrowDown}");+ await user.keyboard("{ArrowUp}");+ expect(screen.getByTestId("profile-edit")).toHaveFocus();+ });++ it("wraps focus from last to first item with ArrowDown", async () => {+ const user = userEvent.setup();+ render(<ProfileActionsMenu {...defaultProps} />);++ // Navigate to the last item (Delete)+ await user.keyboard("{ArrowDown}"); // Rename+ await user.keyboard("{ArrowDown}"); // Set Active+ await user.keyboard("{ArrowDown}"); // Delete+ expect(screen.getByTestId("profile-delete")).toHaveFocus();++ // Press down again to wrap to first+ await user.keyboard("{ArrowDown}");+ expect(screen.getByTestId("profile-edit")).toHaveFocus();+ });++ it("wraps focus from first to last item with ArrowUp", async () => {+ const user = userEvent.setup();+ render(<ProfileActionsMenu {...defaultProps} />);++ // First item is focused (Edit), press up to wrap to last+ await user.keyboard("{ArrowUp}");+ expect(screen.getByTestId("profile-delete")).toHaveFocus();+ });++ it("closes menu when Tab is pressed", async () => {+ const handleClose = vi.fn();+ const user = userEvent.setup();+ render(<ProfileActionsMenu {...defaultProps} onClose={handleClose} />);++ await user.keyboard("{Tab}");+ expect(handleClose).toHaveBeenCalled();+ });+ });+});diff --git a/__tests__/components/settings/llm-profiles/profile-name-input.test.tsx b/__tests__/components/settings/llm-profiles/profile-name-input.test.tsxnew file mode 100644index 0000000000..cbe05ce983--- /dev/null+++ b/__tests__/components/settings/llm-profiles/profile-name-input.test.tsx@@ -0,0 +1,280 @@+import { render, screen } from "@testing-library/react";+import { describe, expect, it, vi } from "vitest";+import userEvent from "@testing-library/user-event";+import { ProfileNameInput } from "#/components/features/settings/llm-profiles/profile-name-input";++vi.mock("react-i18next", () => ({+ useTranslation: () => ({+ t: (key: string) => {+ const translations: Record<string, string> = {+ "SETTINGS$PROFILE_NAME_LABEL": "Profile Name",+ "SETTINGS$PROFILE_NAME_PLACEHOLDER": "Enter profile name",+ "SETTINGS$PROFILE_NAME_RULE":+ "1-64 chars, start with alphanumeric, then alphanumerics or . _ -",+ "COMMON$OPTIONAL": "Optional",+ };+ return translations[key] || key;+ },+ }),+}));++describe("ProfileNameInput", () => {+ it("renders with label and input", () => {+ render(<ProfileNameInput value="" onChange={() => {}} />);++ expect(screen.getByText("Profile Name")).toBeInTheDocument();+ expect(screen.getByRole("textbox")).toBeInTheDocument();+ });++ it("shows the rule text below the input", () => {+ render(+ <ProfileNameInput value="" onChange={() => {}} ruleTestId="rule-text" />,+ );++ const rule = screen.getByTestId("rule-text");+ expect(rule).toHaveTextContent(+ "1-64 chars, start with alphanumeric, then alphanumerics or . _ -",+ );+ });++ it("calls onChange when typing", async () => {+ const handleChange = vi.fn();+ const user = userEvent.setup();++ render(+ <ProfileNameInput+ testId="profile-name"+ value=""+ onChange={handleChange}+ />,+ );++ const input = screen.getByTestId("profile-name");+ await user.type(input, "gpt-4");++ // Each character triggers onChange+ expect(handleChange).toHaveBeenCalledTimes(5);+ // Each call receives just that character since the component is controlled+ // and the test doesn't update the value prop+ expect(handleChange).toHaveBeenNthCalledWith(1, "g");+ expect(handleChange).toHaveBeenNthCalledWith(2, "p");+ expect(handleChange).toHaveBeenNthCalledWith(3, "t");+ expect(handleChange).toHaveBeenNthCalledWith(4, "-");+ expect(handleChange).toHaveBeenNthCalledWith(5, "4");+ });++ it("displays the current value", () => {+ render(+ <ProfileNameInput+ testId="profile-name"+ value="my-profile"+ onChange={() => {}}+ />,+ );++ expect(screen.getByTestId("profile-name")).toHaveValue("my-profile");+ });++ it("shows rule text in gray for valid names", () => {+ render(+ <ProfileNameInput+ value="valid-name"+ onChange={() => {}}+ ruleTestId="rule-text"+ />,+ );++ const rule = screen.getByTestId("rule-text");+ expect(rule).toHaveClass("text-gray-400");+ expect(rule).not.toHaveClass("text-red-400");+ });++ it("shows rule text in red for invalid names", () => {+ render(+ <ProfileNameInput+ value=".invalid-start"+ onChange={() => {}}+ ruleTestId="rule-text"+ />,+ );++ const rule = screen.getByTestId("rule-text");+ expect(rule).toHaveClass("text-red-400");+ expect(rule).not.toHaveClass("text-gray-400");+ });++ it("shows rule text in gray for empty value (treated as valid)", () => {+ render(+ <ProfileNameInput value="" onChange={() => {}} ruleTestId="rule-text" />,+ );++ const rule = screen.getByTestId("rule-text");+ expect(rule).toHaveClass("text-gray-400");+ });++ it("shows rule text in gray for whitespace-only value", () => {+ render(+ <ProfileNameInput value=" " onChange={() => {}} ruleTestId="rule-text" />,+ );++ const rule = screen.getByTestId("rule-text");+ expect(rule).toHaveClass("text-gray-400");+ });++ it("validates names with special characters as invalid", () => {+ render(+ <ProfileNameInput+ value="name with spaces"+ onChange={() => {}}+ ruleTestId="rule-text"+ />,+ );++ const rule = screen.getByTestId("rule-text");+ expect(rule).toHaveClass("text-red-400");+ });++ it("can be disabled", () => {+ render(+ <ProfileNameInput+ testId="profile-name"+ value=""+ onChange={() => {}}+ isDisabled+ />,+ );++ expect(screen.getByTestId("profile-name")).toBeDisabled();+ });++ it("shows custom placeholder", () => {+ render(+ <ProfileNameInput+ testId="profile-name"+ value=""+ onChange={() => {}}+ placeholder="Custom placeholder"+ />,+ );++ expect(screen.getByTestId("profile-name")).toHaveAttribute(+ "placeholder",+ "Custom placeholder",+ );+ });++ it("shows default placeholder when not provided", () => {+ render(+ <ProfileNameInput+ testId="profile-name"+ value=""+ onChange={() => {}}+ />,+ );++ expect(screen.getByTestId("profile-name")).toHaveAttribute(+ "placeholder",+ "Enter profile name",+ );+ });++ it("shows optional label when isOptional is true", () => {+ render(+ <ProfileNameInput value="" onChange={() => {}} isOptional />,+ );++ expect(screen.getByText("Profile Name (Optional)")).toBeInTheDocument();+ });++ it("shows regular label when isOptional is false", () => {+ render(+ <ProfileNameInput value="" onChange={() => {}} isOptional={false} />,+ );++ expect(screen.getByText("Profile Name")).toBeInTheDocument();+ expect(screen.queryByText(/optional/i)).not.toBeInTheDocument();+ });++ describe("boundary conditions", () => {+ it("accepts exactly 64 character names", () => {+ const name64 = "a".repeat(64);+ render(+ <ProfileNameInput+ value={name64}+ onChange={() => {}}+ ruleTestId="rule"+ />,+ );+ // Valid names show gray rule text+ expect(screen.getByTestId("rule")).toHaveClass("text-gray-400");+ });++ it("rejects 65 character names", () => {+ const name65 = "a".repeat(65);+ render(+ <ProfileNameInput+ value={name65}+ onChange={() => {}}+ ruleTestId="rule"+ />,+ );+ // Invalid names show red rule text+ expect(screen.getByTestId("rule")).toHaveClass("text-red-400");+ });++ it("accepts names starting with numbers", () => {+ render(+ <ProfileNameInput+ value="1profile"+ onChange={() => {}}+ ruleTestId="rule"+ />,+ );+ expect(screen.getByTestId("rule")).toHaveClass("text-gray-400");+ });++ it("accepts names with all allowed special characters", () => {+ render(+ <ProfileNameInput+ value="valid.name_with-chars"+ onChange={() => {}}+ ruleTestId="rule"+ />,+ );+ expect(screen.getByTestId("rule")).toHaveClass("text-gray-400");+ });++ it("rejects names starting with special characters", () => {+ render(+ <ProfileNameInput+ value=".invalid"+ onChange={() => {}}+ ruleTestId="rule"+ />,+ );+ expect(screen.getByTestId("rule")).toHaveClass("text-red-400");+ });++ it("rejects names starting with hyphen", () => {+ render(+ <ProfileNameInput+ value="-invalid"+ onChange={() => {}}+ ruleTestId="rule"+ />,+ );+ expect(screen.getByTestId("rule")).toHaveClass("text-red-400");+ });++ it("rejects names starting with underscore", () => {+ render(+ <ProfileNameInput+ value="_invalid"+ onChange={() => {}}+ ruleTestId="rule"+ />,+ );+ expect(screen.getByTestId("rule")).toHaveClass("text-red-400");+ });+ });+});diff --git a/__tests__/components/settings/llm-profiles/profile-row.test.tsx b/__tests__/components/settings/llm-profiles/profile-row.test.tsxnew file mode 100644index 0000000000..9b01e34f44--- /dev/null+++ b/__tests__/components/settings/llm-profiles/profile-row.test.tsx@@ -0,0 +1,160 @@+import { render, screen } from "@testing-library/react";+import { describe, expect, it, vi } from "vitest";+import userEvent from "@testing-library/user-event";+import { ProfileRow } from "#/components/features/settings/llm-profiles/profile-row";+import { ProfileInfo } from "#/api/profiles-service/profiles-service.api";++vi.mock("react-i18next", () => ({+ useTranslation: () => ({+ t: (key: string) => {+ const translations: Record<string, string> = {+ "SETTINGS$PROFILE_ACTIVE": "Active",+ "SETTINGS$PROFILE_MENU": "Profile menu",+ "SETTINGS$PROFILE_EDIT": "Edit",+ "BUTTON$RENAME": "Rename",+ "SETTINGS$PROFILE_SET_ACTIVE": "Set as active",+ "BUTTON$DELETE": "Delete",+ };+ return translations[key] || key;+ },+ }),+}));++const mockProfile: ProfileInfo = {+ name: "gpt-4-profile",+ model: "openai/gpt-4",+ base_url: null,+ api_key_set: true,+};++const defaultProps = {+ profile: mockProfile,+ isActive: false,+ onActivate: vi.fn(),+ onEdit: vi.fn(),+ onRename: vi.fn(),+ onDelete: vi.fn(),+ isActivating: false,+};++describe("ProfileRow", () => {+ it("displays the profile name", () => {+ render(<ProfileRow {...defaultProps} />);++ expect(screen.getByText("gpt-4-profile")).toBeInTheDocument();+ });++ it("displays the model name when present", () => {+ render(<ProfileRow {...defaultProps} />);++ expect(screen.getByText("openai/gpt-4")).toBeInTheDocument();+ });++ it("does not display model when null", () => {+ const profileWithoutModel: ProfileInfo = {+ ...mockProfile,+ model: null,+ };++ render(<ProfileRow {...defaultProps} profile={profileWithoutModel} />);++ expect(screen.queryByText("openai/gpt-4")).not.toBeInTheDocument();+ });++ it("shows Active badge when isActive is true", () => {+ render(<ProfileRow {...defaultProps} isActive />);++ expect(screen.getByTestId("profile-active-badge")).toBeInTheDocument();+ expect(screen.getByText("Active")).toBeInTheDocument();+ });++ it("does not show Active badge when isActive is false", () => {+ render(<ProfileRow {...defaultProps} isActive={false} />);++ expect(screen.queryByTestId("profile-active-badge")).not.toBeInTheDocument();+ });++ it("opens menu when trigger button is clicked", async () => {+ const user = userEvent.setup();++ render(<ProfileRow {...defaultProps} />);++ const menuTrigger = screen.getByTestId("profile-menu-trigger");+ await user.click(menuTrigger);++ expect(screen.getByText("Edit")).toBeInTheDocument();+ expect(screen.getByText("Rename")).toBeInTheDocument();+ expect(screen.getByText("Set as active")).toBeInTheDocument();+ expect(screen.getByText("Delete")).toBeInTheDocument();+ });++ it("toggles menu visibility on multiple clicks", async () => {+ const user = userEvent.setup();++ render(<ProfileRow {...defaultProps} />);++ const menuTrigger = screen.getByTestId("profile-menu-trigger");++ // Menu should be closed initially+ expect(screen.queryByText("Edit")).not.toBeInTheDocument();++ // First click opens the menu+ await user.click(menuTrigger);+ expect(screen.getByText("Edit")).toBeInTheDocument();+ });++ it("calls onEdit when Edit is clicked", async () => {+ const user = userEvent.setup();+ const handleEdit = vi.fn();++ render(<ProfileRow {...defaultProps} onEdit={handleEdit} />);++ await user.click(screen.getByTestId("profile-menu-trigger"));+ await user.click(screen.getByText("Edit"));++ expect(handleEdit).toHaveBeenCalledWith(mockProfile);+ });++ it("calls onRename when Rename is clicked", async () => {+ const user = userEvent.setup();+ const handleRename = vi.fn();++ render(<ProfileRow {...defaultProps} onRename={handleRename} />);++ await user.click(screen.getByTestId("profile-menu-trigger"));+ await user.click(screen.getByText("Rename"));++ expect(handleRename).toHaveBeenCalledWith(mockProfile);+ });++ it("calls onActivate when Set Active is clicked", async () => {+ const user = userEvent.setup();+ const handleActivate = vi.fn();++ render(<ProfileRow {...defaultProps} onActivate={handleActivate} />);++ await user.click(screen.getByTestId("profile-menu-trigger"));+ await user.click(screen.getByText("Set as active"));++ expect(handleActivate).toHaveBeenCalledWith(mockProfile.name);+ });++ it("calls onDelete when Delete is clicked", async () => {+ const user = userEvent.setup();+ const handleDelete = vi.fn();++ render(<ProfileRow {...defaultProps} onDelete={handleDelete} />);++ await user.click(screen.getByTestId("profile-menu-trigger"));+ await user.click(screen.getByText("Delete"));++ expect(handleDelete).toHaveBeenCalledWith(mockProfile);+ });++ it("has accessible menu trigger button", () => {+ render(<ProfileRow {...defaultProps} />);++ const menuTrigger = screen.getByTestId("profile-menu-trigger");+ expect(menuTrigger).toHaveAttribute("aria-label", "Profile menu");+ });+});diff --git a/__tests__/components/settings/llm-profiles/profiles-body.test.tsx b/__tests__/components/settings/llm-profiles/profiles-body.test.tsxnew file mode 100644index 0000000000..211a1bd153--- /dev/null+++ b/__tests__/components/settings/llm-profiles/profiles-body.test.tsx@@ -0,0 +1,126 @@+import { render, screen } from "@testing-library/react";+import { describe, expect, it, vi } from "vitest";+import { ProfilesBody } from "#/components/features/settings/llm-profiles/profiles-body";+import { ProfileInfo } from "#/api/profiles-service/profiles-service.api";++vi.mock("react-i18next", () => ({+ useTranslation: () => ({+ t: (key: string) => {+ const translations: Record<string, string> = {+ "SETTINGS$PROFILES_LOAD_ERROR": "Failed to load profiles",+ "SETTINGS$PROFILES_EMPTY": "No profiles saved yet",+ "SETTINGS$PROFILE_ACTIVE": "Active",+ "SETTINGS$PROFILE_MENU": "Profile menu",+ "SETTINGS$PROFILE_EDIT": "Edit",+ "BUTTON$RENAME": "Rename",+ "SETTINGS$PROFILE_SET_ACTIVE": "Set as active",+ "BUTTON$DELETE": "Delete",+ };+ return translations[key] || key;+ },+ }),+}));++const mockProfiles: ProfileInfo[] = [+ {+ name: "gpt-4-profile",+ model: "openai/gpt-4",+ base_url: null,+ api_key_set: true,+ },+ {+ name: "claude-profile",+ model: "anthropic/claude-3",+ base_url: "https://api.anthropic.com",+ api_key_set: false,+ },+];++const defaultProps = {+ isLoading: false,+ loadError: null,+ profiles: mockProfiles,+ active: "gpt-4-profile",+ onActivate: vi.fn(),+ onEdit: vi.fn(),+ onRename: vi.fn(),+ onDelete: vi.fn(),+ isActivating: false,+};++describe("ProfilesBody", () => {+ it("shows loading spinner when isLoading is true", () => {+ render(<ProfilesBody {...defaultProps} isLoading profiles={[]} />);++ expect(screen.getByTestId("loading-spinner")).toBeInTheDocument();+ });++ it("shows error message when loadError is present", () => {+ render(+ <ProfilesBody+ {...defaultProps}+ loadError={new Error("Network error")}+ profiles={[]}+ />,+ );++ expect(screen.getByText("Failed to load profiles")).toBeInTheDocument();+ });++ it("shows empty state when profiles array is empty", () => {+ render(<ProfilesBody {...defaultProps} profiles={[]} />);++ expect(screen.getByText("No profiles saved yet")).toBeInTheDocument();+ });++ it("renders a list of profiles", () => {+ render(<ProfilesBody {...defaultProps} />);++ expect(screen.getByText("gpt-4-profile")).toBeInTheDocument();+ expect(screen.getByText("openai/gpt-4")).toBeInTheDocument();+ expect(screen.getByText("claude-profile")).toBeInTheDocument();+ expect(screen.getByText("anthropic/claude-3")).toBeInTheDocument();+ });++ it("renders profile rows for each profile", () => {+ render(<ProfilesBody {...defaultProps} />);++ const rows = screen.getAllByTestId("profile-row");+ expect(rows).toHaveLength(2);+ });++ it("shows Active badge for the active profile", () => {+ render(<ProfilesBody {...defaultProps} active="gpt-4-profile" />);++ // Only the active profile should have the badge+ const badges = screen.getAllByTestId("profile-active-badge");+ expect(badges).toHaveLength(1);+ });++ it("loading state takes priority over error", () => {+ render(+ <ProfilesBody+ {...defaultProps}+ isLoading+ loadError={new Error("Error")}+ profiles={[]}+ />,+ );++ expect(screen.getByTestId("loading-spinner")).toBeInTheDocument();+ expect(screen.queryByText("Failed to load profiles")).not.toBeInTheDocument();+ });++ it("error state takes priority over empty state", () => {+ render(+ <ProfilesBody+ {...defaultProps}+ loadError={new Error("Error")}+ profiles={[]}+ />,+ );++ expect(screen.getByText("Failed to load profiles")).toBeInTheDocument();+ expect(screen.queryByText("No profiles saved yet")).not.toBeInTheDocument();+ });+});diff --git a/__tests__/components/settings/llm-profiles/rename-profile-modal.test.tsx b/__tests__/components/settings/llm-profiles/rename-profile-modal.test.tsxnew file mode 100644index 0000000000..12dd4a40fc--- /dev/null+++ b/__tests__/components/settings/llm-profiles/rename-profile-modal.test.tsx@@ -0,0 +1,258 @@+import { render, screen, waitFor } from "@testing-library/react";+import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";+import userEvent from "@testing-library/user-event";+import React from "react";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { RenameProfileModal } from "#/components/features/settings/llm-profiles/rename-profile-modal";+import { ProfileInfo } from "#/api/profiles-service/profiles-service.api";+import ProfilesService from "#/api/profiles-service/profiles-service.api";++vi.mock("react-i18next", () => ({+ useTranslation: () => ({+ t: (key: string, params?: Record<string, string>) => {+ const translations: Record<string, string> = {+ "SETTINGS$PROFILE_RENAME_TITLE": "Rename Profile",+ "SETTINGS$PROFILE_NAME_LABEL": "Profile Name",+ "SETTINGS$PROFILE_NAME_PLACEHOLDER": "Enter profile name",+ "SETTINGS$PROFILE_NAME_RULE":+ "1-64 chars, start with alphanumeric, then alphanumerics or . _ -",+ "SETTINGS$PROFILE_RENAMED": params?.name+ ? `Profile renamed to ${params.name}`+ : "Profile renamed",+ "BUTTON$RENAME": "Rename",+ "BUTTON$CANCEL": "Cancel",+ "ERROR$GENERIC": "An error occurred",+ };+ return translations[key] || key;+ },+ }),+}));++vi.mock("#/api/profiles-service/profiles-service.api");++vi.mock("#/utils/custom-toast-handlers", () => ({+ displaySuccessToast: vi.fn(),+ displayErrorToast: vi.fn(),+}));++const mockProfile: ProfileInfo = {+ name: "old-profile-name",+ model: "openai/gpt-4",+ base_url: null,+ api_key_set: true,+};++describe("RenameProfileModal", () => {+ let queryClient: QueryClient;++ const renderModal = (profile: ProfileInfo | null, onClose = vi.fn()) => {+ return render(+ <QueryClientProvider client={queryClient}>+ <RenameProfileModal profile={profile} onClose={onClose} />+ </QueryClientProvider>,+ );+ };++ beforeEach(() => {+ queryClient = new QueryClient({+ defaultOptions: {+ queries: { retry: false },+ mutations: { retry: false },+ },+ });+ });++ afterEach(() => {+ queryClient.clear();+ vi.clearAllMocks();+ });++ it("returns null when profile is null", () => {+ const { container } = renderModal(null);+ expect(container.firstChild).toBeNull();+ });++ it("renders the modal when profile is provided", () => {+ renderModal(mockProfile);+ expect(screen.getByTestId("rename-profile-modal")).toBeInTheDocument();+ });++ it("pre-fills the input with the current profile name", () => {+ renderModal(mockProfile);+ expect(screen.getByTestId("rename-profile-input")).toHaveValue(+ "old-profile-name",+ );+ });++ it("shows Rename and Cancel buttons", () => {+ renderModal(mockProfile);+ expect(screen.getByTestId("rename-profile-submit")).toHaveTextContent(+ "Rename",+ );+ expect(screen.getByText("Cancel")).toBeInTheDocument();+ });++ it("calls onClose when Cancel is clicked", async () => {+ const user = userEvent.setup();+ const handleClose = vi.fn();+ renderModal(mockProfile, handleClose);++ await user.click(screen.getByText("Cancel"));++ expect(handleClose).toHaveBeenCalledTimes(1);+ });++ it("calls onClose when name is unchanged and Rename is clicked", async () => {+ const user = userEvent.setup();+ const handleClose = vi.fn();+ renderModal(mockProfile, handleClose);++ // Name is already "old-profile-name", so clicking Rename should just close+ await user.click(screen.getByTestId("rename-profile-submit"));++ expect(handleClose).toHaveBeenCalledTimes(1);+ expect(ProfilesService.renameProfile).not.toHaveBeenCalled();+ });++ it("calls renameProfile and closes on successful rename", async () => {+ const user = userEvent.setup();+ const handleClose = vi.fn();+ vi.mocked(ProfilesService.renameProfile).mockResolvedValue({+ name: "new-profile-name",+ message: "Profile renamed",+ });++ renderModal(mockProfile, handleClose);++ const input = screen.getByTestId("rename-profile-input");+ await user.clear(input);+ await user.type(input, "new-profile-name");+ await user.click(screen.getByTestId("rename-profile-submit"));++ await waitFor(() => {+ expect(ProfilesService.renameProfile).toHaveBeenCalledWith(+ "old-profile-name",+ "new-profile-name",+ );+ });++ expect(handleClose).toHaveBeenCalled();+ });++ it("disables submit button when name is invalid", async () => {+ const user = userEvent.setup();+ renderModal(mockProfile);++ const input = screen.getByTestId("rename-profile-input");+ await user.clear(input);+ await user.type(input, ".invalid-name");++ const submitButton = screen.getByTestId("rename-profile-submit");+ expect(submitButton).toBeDisabled();+ });++ it("shows validation error styling for invalid names", async () => {+ const user = userEvent.setup();+ renderModal(mockProfile);++ const input = screen.getByTestId("rename-profile-input");+ await user.clear(input);+ await user.type(input, ".invalid-name");++ const rule = screen.getByTestId("rename-profile-rule");+ expect(rule).toHaveClass("text-red-400");+ });++ it("updates input value when a different profile is passed", () => {+ const { rerender } = render(+ <QueryClientProvider client={queryClient}>+ <RenameProfileModal profile={mockProfile} onClose={vi.fn()} />+ </QueryClientProvider>,+ );++ expect(screen.getByTestId("rename-profile-input")).toHaveValue(+ "old-profile-name",+ );++ const newProfile: ProfileInfo = {+ ...mockProfile,+ name: "different-profile",+ };++ rerender(+ <QueryClientProvider client={queryClient}>+ <RenameProfileModal profile={newProfile} onClose={vi.fn()} />+ </QueryClientProvider>,+ );++ expect(screen.getByTestId("rename-profile-input")).toHaveValue(+ "different-profile",+ );+ });++ it("shows error toast and keeps modal open on rename failure", async () => {+ const user = userEvent.setup();+ const { displayErrorToast } = await import(+ "#/utils/custom-toast-handlers"+ );+ vi.mocked(ProfilesService.renameProfile).mockRejectedValue(+ new Error("Name already exists"),+ );++ const onClose = vi.fn();+ renderModal(mockProfile, onClose);++ const input = screen.getByTestId("rename-profile-input");+ await user.clear(input);+ await user.type(input, "duplicate-name");+ await user.click(screen.getByTestId("rename-profile-submit"));++ await waitFor(() => {+ expect(displayErrorToast).toHaveBeenCalledWith("Name already exists");+ });++ // Modal should stay open after error (onClose not called)+ expect(onClose).not.toHaveBeenCalled();+ expect(screen.getByTestId("rename-profile-modal")).toBeInTheDocument();+ });++ it("submits form when Enter key is pressed with valid name", async () => {+ const user = userEvent.setup();+ const handleClose = vi.fn();+ vi.mocked(ProfilesService.renameProfile).mockResolvedValue({+ name: "new-name",+ message: "Profile renamed",+ });++ renderModal(mockProfile, handleClose);++ const input = screen.getByTestId("rename-profile-input");+ await user.clear(input);+ await user.type(input, "new-name{Enter}");++ await waitFor(() => {+ expect(ProfilesService.renameProfile).toHaveBeenCalledWith(+ "old-profile-name",+ "new-name",+ );+ });++ expect(handleClose).toHaveBeenCalled();+ });++ it("does not submit form when Enter key is pressed with invalid name", async () => {+ const user = userEvent.setup();+ const handleClose = vi.fn();++ renderModal(mockProfile, handleClose);++ const input = screen.getByTestId("rename-profile-input");+ await user.clear(input);+ await user.type(input, ".invalid{Enter}");++ // Should not call rename or close+ expect(ProfilesService.renameProfile).not.toHaveBeenCalled();+ expect(handleClose).not.toHaveBeenCalled();+ expect(screen.getByTestId("rename-profile-modal")).toBeInTheDocument();+ });+});diff --git a/src/components/features/settings/api-key-modal-base.tsx b/src/components/features/settings/api-key-modal-base.tsxnew file mode 100644index 0000000000..cc4fb14f8e--- /dev/null+++ b/src/components/features/settings/api-key-modal-base.tsx@@ -0,0 +1,93 @@+import React, { ReactNode, useEffect, useRef } from "react";+import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";++interface ApiKeyModalBaseProps {+ isOpen: boolean;+ title: string;+ width?: string;+ children: ReactNode;+ footer: ReactNode;+ /** Called when the modal should close (e.g., Escape key or backdrop click) */+ onClose?: () => void;+ /** Ref to an element that should receive initial focus when modal opens */+ initialFocusRef?: React.RefObject<HTMLElement | null>;+}++export function ApiKeyModalBase({+ isOpen,+ title,+ width = "500px",+ children,+ footer,+ onClose,+ initialFocusRef,+}: ApiKeyModalBaseProps) {+ const modalRef = useRef<HTMLDivElement>(null);++ // Focus management: set initial focus and trap focus within modal+ useEffect(() => {+ if (!isOpen) return undefined;++ // Set initial focus+ const focusTarget = initialFocusRef?.current ?? modalRef.current;+ if (focusTarget) {+ // Small delay to ensure modal is fully rendered+ const timeoutId = setTimeout(() => {+ focusTarget.focus();+ }, 0);+ return () => clearTimeout(timeoutId);+ }+ return undefined;+ }, [isOpen, initialFocusRef]);++ // Focus trap: keep focus within modal+ useEffect(() => {+ if (!isOpen || !modalRef.current) return undefined;++ const modal = modalRef.current;++ const handleKeyDown = (e: KeyboardEvent) => {+ if (e.key !== "Tab") return;++ const focusableElements = modal.querySelectorAll<HTMLElement>(+ 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',+ );++ const firstElement = focusableElements[0];+ const lastElement = focusableElements[focusableElements.length - 1];++ if (e.shiftKey && document.activeElement === firstElement) {+ e.preventDefault();+ lastElement?.focus();+ } else if (!e.shiftKey && document.activeElement === lastElement) {+ e.preventDefault();+ firstElement?.focus();+ }+ };++ document.addEventListener("keydown", handleKeyDown);+ return () => document.removeEventListener("keydown", handleKeyDown);+ }, [isOpen]);++ if (!isOpen) return null;++ return (+ <ModalBackdrop onClose={onClose}>+ <div+ ref={modalRef}+ tabIndex={-1}+ role="dialog"+ aria-modal="true"+ aria-labelledby="modal-title"+ className="bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-tertiary"+ style={{ width }}+ >+ <h3 id="modal-title" className="text-xl font-bold">+ {title}+ </h3>+ {children}+ <div className="w-full flex gap-2 mt-2">{footer}</div>+ </div>+ </ModalBackdrop>+ );+}diff --git a/src/components/features/settings/brand-button.tsx b/src/components/features/settings/brand-button.tsxindex 4dc98e3613..f1b6eb22f6 100644--- a/src/components/features/settings/brand-button.tsx+++ b/src/components/features/settings/brand-button.tsx@@ -1,40 +1,57 @@+import { forwardRef } from "react";import { cn } from "#/utils/utils";interface BrandButtonProps {testId?: string;name?: string;- variant: "primary" | "secondary" | "danger" | "ghost-danger";+ variant: "primary" | "secondary" | "tertiary" | "danger" | "ghost-danger";type: React.ButtonHTMLAttributes<HTMLButtonElement>["type"];isDisabled?: boolean;className?: string;onClick?: (event?: React.MouseEvent<HTMLButtonElement>) => void;startContent?: React.ReactNode;+ /** Accessible label for icon-only buttons */+ ariaLabel?: string;+ /** Indicates busy/loading state for screen readers */+ "aria-busy"?: boolean;}-export function BrandButton({- testId,- name,- children,- variant,- type,- isDisabled,- className,- onClick,- startContent,-}: React.PropsWithChildren<BrandButtonProps>) {+export const BrandButton = forwardRef<+ HTMLButtonElement,+ React.PropsWithChildren<BrandButtonProps>+>(function BrandButton(+ {+ testId,+ name,+ children,+ variant,+ type,+ isDisabled,+ className,+ onClick,+ startContent,+ ariaLabel,+ "aria-busy": ariaBusy,+ },+ ref,+) {return (<button+ ref={ref}name={name}data-testid={testId}disabled={isDisabled}- // The type is alreadt passed as a prop to the button component- // eslint-disable-next-line react/button-has-type+ // The type is already passed as a prop to the button component+type={type}onClick={onClick}+ aria-label={ariaLabel}+ aria-busy={ariaBusy}className={cn("w-fit p-2 text-sm rounded-sm disabled:opacity-30 disabled:cursor-not-allowed hover:opacity-80 cursor-pointer",variant === "primary" && "bg-primary text-[#0D0F11]",variant === "secondary" && "border border-primary text-primary",+ variant === "tertiary" && "bg-neutral-600 text-white",variant === "danger" && "bg-red-600 text-white hover:bg-red-700",variant === "ghost-danger" &&"bg-transparent text-red-600 underline hover:text-red-700 hover:no-underline font-medium",@@ -46,4 +63,4 @@ export function BrandButton({{children}</button>);-}+});diff --git a/src/components/features/settings/llm-profiles/delete-profile-modal.tsx b/src/components/features/settings/llm-profiles/delete-profile-modal.tsxnew file mode 100644index 0000000000..84a4460479--- /dev/null+++ b/src/components/features/settings/llm-profiles/delete-profile-modal.tsx@@ -0,0 +1,98 @@+import { useRef } from "react";+import { useTranslation } from "react-i18next";+import { BrandButton } from "#/components/features/settings/brand-button";+import { LoadingSpinner } from "#/components/shared/loading-spinner";+import { ApiKeyModalBase } from "#/components/features/settings/api-key-modal-base";+import { ProfileInfo } from "#/api/profiles-service/profiles-service.api";+import { useDeleteLlmProfile } from "#/hooks/mutation/use-delete-llm-profile";+import {+ displayErrorToast,+ displaySuccessToast,+} from "#/utils/custom-toast-handlers";+import { I18nKey } from "#/i18n/declaration";++interface DeleteProfileModalProps {+ profile: ProfileInfo | null;+ onClose: () => void;+}++export function DeleteProfileModal({+ profile,+ onClose,+}: DeleteProfileModalProps) {+ const { t } = useTranslation("openhands");+ const deleteProfile = useDeleteLlmProfile();+ const cancelButtonRef = useRef<HTMLButtonElement>(null);++ if (!profile) return null;++ const handleDelete = async () => {+ try {+ await deleteProfile.mutateAsync(profile.name);+ displaySuccessToast(+ t(I18nKey.SETTINGS$PROFILE_DELETED, { name: profile.name }),+ );+ onClose();+ } catch (error) {+ const message =+ error instanceof Error ? error.message : t(I18nKey.ERROR$GENERIC);+ displayErrorToast(message);+ }+ };++ // Handle close only if not pending to prevent inconsistent state+ const handleClose = () => {+ if (!deleteProfile.isPending) {+ onClose();+ }+ };++ const footer = (+ <>+ <BrandButton+ testId="delete-profile-confirm"+ type="button"+ variant="danger"+ className="grow"+ onClick={handleDelete}+ isDisabled={deleteProfile.isPending}+ aria-busy={deleteProfile.isPending}+ >+ {deleteProfile.isPending ? (+ <>+ <LoadingSpinner size="small" />+ <span className="sr-only">{t(I18nKey.BUTTON$DELETE)}</span>+ </>+ ) : (+ t(I18nKey.BUTTON$DELETE)+ )}+ </BrandButton>+ <BrandButton+ ref={cancelButtonRef}+ type="button"+ variant="tertiary"+ className="grow"+ onClick={handleClose}+ isDisabled={deleteProfile.isPending}+ >+ {t(I18nKey.BUTTON$CANCEL)}+ </BrandButton>+ </>+ );++ return (+ <ApiKeyModalBase+ isOpen+ title={t(I18nKey.SETTINGS$PROFILE_DELETE_TITLE)}+ footer={footer}+ onClose={handleClose}+ initialFocusRef={cancelButtonRef}+ >+ <p className="text-sm break-all">+ {t(I18nKey.SETTINGS$PROFILE_DELETE_CONFIRMATION, {+ name: profile.name,+ })}+ </p>+ </ApiKeyModalBase>+ );+}diff --git a/src/components/features/settings/llm-profiles/index.ts b/src/components/features/settings/llm-profiles/index.tsnew file mode 100644index 0000000000..6a4a2c3eae--- /dev/null+++ b/src/components/features/settings/llm-profiles/index.ts@@ -0,0 +1,7 @@+export { LlmProfilesManager } from "./llm-profiles-manager";+export { ProfilesBody } from "./profiles-body";+export { ProfileRow } from "./profile-row";+export { ProfileActionsMenu } from "./profile-actions-menu";+export { RenameProfileModal } from "./rename-profile-modal";+export { DeleteProfileModal } from "./delete-profile-modal";+export { ProfileNameInput } from "./profile-name-input";diff --git a/src/components/features/settings/llm-profiles/llm-profiles-manager.tsx b/src/components/features/settings/llm-profiles/llm-profiles-manager.tsxnew file mode 100644index 0000000000..af646690d4--- /dev/null+++ b/src/components/features/settings/llm-profiles/llm-profiles-manager.tsx@@ -0,0 +1,95 @@+import { useState } from "react";+import { useTranslation } from "react-i18next";+import { BrandButton } from "#/components/features/settings/brand-button";+import { RenameProfileModal } from "./rename-profile-modal";+import { DeleteProfileModal } from "./delete-profile-modal";+import { ProfilesBody } from "./profiles-body";+import { ProfileInfo } from "#/api/profiles-service/profiles-service.api";+import { useLlmProfiles } from "#/hooks/query/use-llm-profiles";+import { useActivateLlmProfile } from "#/hooks/mutation/use-activate-llm-profile";+import {+ displayErrorToast,+ displaySuccessToast,+} from "#/utils/custom-toast-handlers";+import { I18nKey } from "#/i18n/declaration";++interface LlmProfilesManagerProps {+ onAddProfile?: () => void;+ onEditProfile?: (profile: ProfileInfo) => void;+}++export function LlmProfilesManager({+ onAddProfile,+ onEditProfile,+}: LlmProfilesManagerProps) {+ const { t } = useTranslation("openhands");+ const { data, isLoading, error } = useLlmProfiles();+ const activateProfile = useActivateLlmProfile();+ const [profileToRename, setProfileToRename] = useState<ProfileInfo | null>(+ null,+ );+ const [profileToDelete, setProfileToDelete] = useState<ProfileInfo | null>(+ null,+ );++ const profiles = data?.profiles ?? [];+ const active = data?.active_profile ?? null;++ const handleActivate = async (name: string) => {+ try {+ await activateProfile.mutateAsync(name);+ displaySuccessToast(t(I18nKey.SETTINGS$PROFILE_ACTIVATED, { name }));+ } catch (error) {+ console.error("Failed to activate profile:", error);+ displayErrorToast(t(I18nKey.ERROR$GENERIC));+ }+ };++ const handleEdit = (profile: ProfileInfo) => {+ onEditProfile?.(profile);+ };++ return (+ <>+ <div className="flex flex-col gap-4">+ <div className="flex flex-wrap items-center justify-between gap-3">+ <h2 className="text-base font-semibold text-white">+ {t(I18nKey.SETTINGS$AVAILABLE_PROFILES)}+ </h2>+ {onAddProfile ? (+ <BrandButton+ testId="add-llm-profile"+ type="button"+ variant="secondary"+ className="ml-auto"+ onClick={onAddProfile}+ >+ {t(I18nKey.SETTINGS$ADD_LLM_PROFILE)}+ </BrandButton>+ ) : null}+ </div>++ <ProfilesBody+ isLoading={isLoading}+ loadError={error ?? null}+ profiles={profiles}+ active={active}+ onActivate={handleActivate}+ onEdit={handleEdit}+ onRename={setProfileToRename}+ onDelete={setProfileToDelete}+ isActivating={activateProfile.isPending}+ />+ </div>++ <RenameProfileModal+ profile={profileToRename}+ onClose={() => setProfileToRename(null)}+ />+ <DeleteProfileModal+ profile={profileToDelete}+ onClose={() => setProfileToDelete(null)}+ />+ </>+ );+}diff --git a/src/components/features/settings/llm-profiles/profile-actions-menu.tsx b/src/components/features/settings/llm-profiles/profile-actions-menu.tsxnew file mode 100644index 0000000000..f2c9b6fdd9--- /dev/null+++ b/src/components/features/settings/llm-profiles/profile-actions-menu.tsx@@ -0,0 +1,172 @@+import { useEffect, useRef, useCallback } from "react";+import { useTranslation } from "react-i18next";+import { cn } from "#/utils/utils";+import { I18nKey } from "#/i18n/declaration";++interface MenuItemProps {+ index: number;+ label: string;+ onClick: () => void;+ onKeyDown: (e: React.KeyboardEvent, index: number) => void;+ menuItemsRef: React.MutableRefObject<(HTMLButtonElement | null)[]>;+ disabled?: boolean;+ className?: string;+ testId: string;+}++function MenuItem({+ index,+ label,+ onClick,+ onKeyDown,+ menuItemsRef,+ disabled,+ className,+ testId,+}: MenuItemProps) {+ return (+ <button+ ref={(el) => {+ // eslint-disable-next-line no-param-reassign+ menuItemsRef.current[index] = el;+ }}+ type="button"+ onClick={onClick}+ onKeyDown={(e) => onKeyDown(e, index)}+ disabled={disabled}+ className={cn(+ "w-full text-left px-4 py-2 text-sm text-white hover:bg-tertiary cursor-pointer",+ "disabled:opacity-50 disabled:cursor-not-allowed",+ className,+ )}+ role="menuitem"+ data-testid={testId}+ >+ {label}+ </button>+ );+}++interface ProfileActionsMenuProps {+ onEdit: () => void;+ onRename: () => void;+ onSetActive: () => void;+ onDelete: () => void;+ isActive: boolean;+ isActivating: boolean;+ onClose: () => void;+}++export function ProfileActionsMenu({+ onEdit,+ onRename,+ onSetActive,+ onDelete,+ isActive,+ isActivating,+ onClose,+}: ProfileActionsMenuProps) {+ const { t } = useTranslation("openhands");+ const menuRef = useRef<HTMLDivElement>(null);+ const menuItemsRef = useRef<(HTMLButtonElement | null)[]>([]);++ // Focus first item when menu opens+ useEffect(() => {+ menuItemsRef.current[0]?.focus();+ }, []);++ useEffect(() => {+ const handleClickOutside = (event: MouseEvent) => {+ const target = event.target as Node;+ if (menuRef.current && !menuRef.current.contains(target)) {+ onClose();+ }+ };++ const handleEscape = (event: KeyboardEvent) => {+ if (event.key === "Escape") {+ onClose();+ }+ };++ document.addEventListener("mousedown", handleClickOutside);+ document.addEventListener("keydown", handleEscape);++ return () => {+ document.removeEventListener("mousedown", handleClickOutside);+ document.removeEventListener("keydown", handleEscape);+ };+ }, [onClose]);++ const handleAction = (action: () => void) => {+ action();+ onClose();+ };++ const handleKeyDown = useCallback(+ (e: React.KeyboardEvent, currentIndex: number) => {+ if (e.key === "Tab") {+ onClose();+ return;+ }+ const itemCount = menuItemsRef.current.filter(Boolean).length;+ if (e.key === "ArrowDown") {+ e.preventDefault();+ const nextIndex = (currentIndex + 1) % itemCount;+ menuItemsRef.current[nextIndex]?.focus();+ } else if (e.key === "ArrowUp") {+ e.preventDefault();+ const prevIndex = (currentIndex - 1 + itemCount) % itemCount;+ menuItemsRef.current[prevIndex]?.focus();+ }+ },+ [onClose],+ );++ const setActiveDisabled = isActive || isActivating;++ return (+ <div+ ref={menuRef}+ className="absolute right-0 top-full mt-1 z-10 bg-base-secondary border border-tertiary rounded-md shadow-lg py-1 min-w-[160px]"+ role="menu"+ aria-orientation="vertical"+ data-testid="profile-actions-menu"+ >+ <MenuItem+ index={0}+ label={t(I18nKey.SETTINGS$PROFILE_EDIT)}+ onClick={() => handleAction(onEdit)}+ onKeyDown={handleKeyDown}+ menuItemsRef={menuItemsRef}+ testId="profile-edit"+ />+ <MenuItem+ index={1}+ label={t(I18nKey.BUTTON$RENAME)}+ onClick={() => handleAction(onRename)}+ onKeyDown={handleKeyDown}+ menuItemsRef={menuItemsRef}+ testId="profile-rename"+ />+ <MenuItem+ index={2}+ label={t(I18nKey.SETTINGS$PROFILE_SET_ACTIVE)}+ onClick={() => handleAction(onSetActive)}+ onKeyDown={handleKeyDown}+ menuItemsRef={menuItemsRef}+ disabled={setActiveDisabled}+ testId="profile-set-active"+ />+ <MenuItem+ index={3}+ label={t(I18nKey.BUTTON$DELETE)}+ onClick={() => handleAction(onDelete)}+ onKeyDown={handleKeyDown}+ menuItemsRef={menuItemsRef}+ className="text-red-400"+ testId="profile-delete"+ />+ </div>+ );+}diff --git a/src/components/features/settings/llm-profiles/profile-name-input.tsx b/src/components/features/settings/llm-profiles/profile-name-input.tsxnew file mode 100644index 0000000000..879c6200af--- /dev/null+++ b/src/components/features/settings/llm-profiles/profile-name-input.tsx@@ -0,0 +1,79 @@+import React, { forwardRef } from "react";+import { useTranslation } from "react-i18next";+import { SettingsInput } from "#/components/features/settings/settings-input";+import { PROFILE_NAME_PATTERN } from "#/utils/derive-profile-name";+import { I18nKey } from "#/i18n/declaration";++interface ProfileNameInputProps {+ testId?: string;+ ruleTestId?: string;+ value: string;+ onChange: (value: string) => void;+ onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;+ placeholder?: string;+ isDisabled?: boolean;+ /** Render label as "Name (Optional)" when this field isn't required. */+ isOptional?: boolean;+ /** When true, empty values will show red validation styling (required field behavior). */+ isRequired?: boolean;+}++export const ProfileNameInput = forwardRef<+ HTMLInputElement,+ ProfileNameInputProps+>(function ProfileNameInput(+ {+ testId,+ ruleTestId,+ value,+ onChange,+ onKeyDown,+ placeholder,+ isDisabled,+ isOptional,+ isRequired = false,+ },+ ref,+) {+ const { t } = useTranslation("openhands");+ const trimmed = value.trim();+ // When required, empty string is invalid. Otherwise, empty is valid (optional).+ const isValid = isRequired+ ? trimmed !== "" && PROFILE_NAME_PATTERN.test(trimmed)+ : trimmed === "" || PROFILE_NAME_PATTERN.test(trimmed);+ const label = isOptional+ ? `${t(I18nKey.SETTINGS$PROFILE_NAME_LABEL)} (${t(I18nKey.COMMON$OPTIONAL)})`+ : t(I18nKey.SETTINGS$PROFILE_NAME_LABEL);++ // Generate a stable ID for the rule element to link with aria-describedby+ const ruleId = React.useId();+ const describedById = ruleTestId ?? `${ruleId}-rule`;++ return (+ <div className="flex flex-col gap-2">+ <SettingsInput+ ref={ref}+ testId={testId}+ label={label}+ type="text"+ className="w-full"+ value={value}+ placeholder={+ placeholder ?? t(I18nKey.SETTINGS$PROFILE_NAME_PLACEHOLDER)+ }+ onChange={onChange}+ onKeyDown={onKeyDown}+ isDisabled={isDisabled}+ ariaDescribedBy={describedById}+ ariaInvalid={!isValid}+ />+ <p+ id={describedById}+ data-testid={ruleTestId}+ className={`text-xs ${isValid ? "text-gray-400" : "text-red-400"}`}+ >+ {t(I18nKey.SETTINGS$PROFILE_NAME_RULE)}+ </p>+ </div>+ );+});diff --git a/src/components/features/settings/llm-profiles/profile-row.tsx b/src/components/features/settings/llm-profiles/profile-row.tsxnew file mode 100644index 0000000000..98f7e8b003--- /dev/null+++ b/src/components/features/settings/llm-profiles/profile-row.tsx@@ -0,0 +1,83 @@+import { useState } from "react";+import { useTranslation } from "react-i18next";+import { ProfileActionsMenu } from "./profile-actions-menu";+import { ProfileInfo } from "#/api/profiles-service/profiles-service.api";+import { I18nKey } from "#/i18n/declaration";+import ThreeDotsVerticalIcon from "#/icons/three-dots-vertical.svg?react";++interface ProfileRowProps {+ profile: ProfileInfo;+ isActive: boolean;+ onActivate: (name: string) => void;+ onEdit: (profile: ProfileInfo) => void;+ onRename: (profile: ProfileInfo) => void;+ onDelete: (profile: ProfileInfo) => void;+ isActivating: boolean;+}++export function ProfileRow({+ profile,+ isActive,+ onActivate,+ onEdit,+ onRename,+ onDelete,+ isActivating,+}: ProfileRowProps) {+ const { t } = useTranslation("openhands");+ const [menuOpen, setMenuOpen] = useState(false);++ return (+ <div+ data-testid="profile-row"+ className="flex items-center justify-between gap-3 px-5 py-4"+ >+ <div className="flex flex-col gap-1 min-w-0 flex-1 sm:flex-row sm:items-center sm:gap-3">+ <span+ className="font-medium text-white truncate min-w-0 max-w-full"+ title={profile.name}+ >+ {profile.name}+ </span>+ {profile.model ? (+ <span+ className="text-sm text-gray-400 truncate min-w-0 max-w-full"+ title={profile.model}+ >+ {profile.model}+ </span>+ ) : null}+ {isActive && (+ <span+ className="text-xs bg-success text-white font-semibold rounded-full px-2.5 py-0.5 whitespace-nowrap self-start sm:self-auto"+ data-testid="profile-active-badge"+ >+ {t(I18nKey.SETTINGS$PROFILE_ACTIVE)}+ </span>+ )}+ </div>+ <div className="relative shrink-0">+ <button+ type="button"+ onClick={() => setMenuOpen((open) => !open)}+ aria-label={t(I18nKey.SETTINGS$PROFILE_MENU)}+ className="cursor-pointer text-gray-300 hover:text-white p-2 border border-tertiary rounded-md"+ data-testid="profile-menu-trigger"+ >+ <ThreeDotsVerticalIcon width={16} height={16} />+ </button>+ {menuOpen && (+ <ProfileActionsMenu+ onEdit={() => onEdit(profile)}+ onRename={() => onRename(profile)}+ onSetActive={() => onActivate(profile.name)}+ onDelete={() => onDelete(profile)}+ isActive={isActive}+ isActivating={isActivating}+ onClose={() => setMenuOpen(false)}+ />+ )}+ </div>+ </div>+ );+}diff --git a/src/components/features/settings/llm-profiles/profiles-body.tsx b/src/components/features/settings/llm-profiles/profiles-body.tsxnew file mode 100644index 0000000000..03c61397bd--- /dev/null+++ b/src/components/features/settings/llm-profiles/profiles-body.tsx@@ -0,0 +1,72 @@+import { useTranslation } from "react-i18next";+import { LoadingSpinner } from "#/components/shared/loading-spinner";+import { ProfileRow } from "./profile-row";+import { ProfileInfo } from "#/api/profiles-service/profiles-service.api";+import { I18nKey } from "#/i18n/declaration";++interface ProfilesBodyProps {+ isLoading: boolean;+ loadError: Error | null;+ profiles: ProfileInfo[];+ active: string | null;+ onActivate: (name: string) => void;+ onEdit: (profile: ProfileInfo) => void;+ onRename: (profile: ProfileInfo) => void;+ onDelete: (profile: ProfileInfo) => void;+ isActivating: boolean;+}++export function ProfilesBody({+ isLoading,+ loadError,+ profiles,+ active,+ onActivate,+ onEdit,+ onRename,+ onDelete,+ isActivating,+}: ProfilesBodyProps) {+ const { t } = useTranslation("openhands");++ if (isLoading) {+ return (+ <div className="flex justify-center p-4">+ <LoadingSpinner size="large" />+ </div>+ );+ }++ if (loadError) {+ return (+ <p className="text-sm text-red-400">+ {t(I18nKey.SETTINGS$PROFILES_LOAD_ERROR)}+ </p>+ );+ }++ if (profiles.length === 0) {+ return (+ <p className="text-sm text-gray-400 italic">+ {t(I18nKey.SETTINGS$PROFILES_EMPTY)}+ </p>+ );+ }++ return (+ <div className="border border-tertiary rounded-md divide-y divide-tertiary">+ {profiles.map((profile) => (+ <ProfileRow+ key={profile.name}+ profile={profile}+ isActive={profile.name === active}+ onActivate={onActivate}+ onEdit={onEdit}+ onRename={onRename}+ onDelete={onDelete}+ isActivating={isActivating}+ />+ ))}+ </div>+ );+}diff --git a/src/components/features/settings/llm-profiles/rename-profile-modal.tsx b/src/components/features/settings/llm-profiles/rename-profile-modal.tsxnew file mode 100644index 0000000000..bdc13838d1--- /dev/null+++ b/src/components/features/settings/llm-profiles/rename-profile-modal.tsx@@ -0,0 +1,128 @@+import { useEffect, useRef, useState } from "react";+import { useTranslation } from "react-i18next";+import { BrandButton } from "#/components/features/settings/brand-button";+import { ProfileNameInput } from "./profile-name-input";+import { LoadingSpinner } from "#/components/shared/loading-spinner";+import { ApiKeyModalBase } from "#/components/features/settings/api-key-modal-base";+import { ProfileInfo } from "#/api/profiles-service/profiles-service.api";+import { useRenameLlmProfile } from "#/hooks/mutation/use-rename-llm-profile";+import {+ displayErrorToast,+ displaySuccessToast,+} from "#/utils/custom-toast-handlers";+import { I18nKey } from "#/i18n/declaration";+import { PROFILE_NAME_PATTERN } from "#/utils/derive-profile-name";++interface RenameProfileModalProps {+ profile: ProfileInfo | null;+ onClose: () => void;+}++export function RenameProfileModal({+ profile,+ onClose,+}: RenameProfileModalProps) {+ const { t } = useTranslation("openhands");+ const [newName, setNewName] = useState("");+ const renameProfile = useRenameLlmProfile();+ const inputRef = useRef<HTMLInputElement>(null);++ useEffect(() => {+ setNewName(profile?.name ?? "");+ }, [profile?.name]);++ if (!profile) return null;++ const isUnchanged = newName === profile.name;+ // Explicit empty check matches ProfileNameInput's isRequired validation+ const isValid = newName !== "" && PROFILE_NAME_PATTERN.test(newName);++ // Trim whitespace on input change to avoid user confusion+ const handleNameChange = (value: string) => {+ setNewName(value.trim());+ };++ const handleSubmit = async () => {+ if (!isValid) {+ displayErrorToast(t(I18nKey.SETTINGS$PROFILE_NAME_RULE));+ return;+ }+ if (isUnchanged) {+ onClose();+ return;+ }++ try {+ await renameProfile.mutateAsync({ name: profile.name, newName });+ displaySuccessToast(+ t(I18nKey.SETTINGS$PROFILE_RENAMED, { name: newName }),+ );+ onClose();+ } catch (error) {+ const message =+ error instanceof Error ? error.message : t(I18nKey.ERROR$GENERIC);+ displayErrorToast(message);+ }+ };++ // Handle close only if not pending to prevent inconsistent state+ const handleClose = () => {+ if (!renameProfile.isPending) {+ onClose();+ }+ };++ const footer = (+ <>+ <BrandButton+ testId="rename-profile-submit"+ type="button"+ variant="primary"+ className="grow"+ onClick={handleSubmit}+ isDisabled={renameProfile.isPending || !isValid}+ >+ {renameProfile.isPending ? (+ <LoadingSpinner size="small" />+ ) : (+ t(I18nKey.BUTTON$RENAME)+ )}+ </BrandButton>+ <BrandButton+ type="button"+ variant="tertiary"+ className="grow"+ onClick={handleClose}+ isDisabled={renameProfile.isPending}+ >+ {t(I18nKey.BUTTON$CANCEL)}+ </BrandButton>+ </>+ );++ return (+ <ApiKeyModalBase+ isOpen+ title={t(I18nKey.SETTINGS$PROFILE_RENAME_TITLE)}+ footer={footer}+ onClose={handleClose}+ initialFocusRef={inputRef}+ >+ <div data-testid="rename-profile-modal" className="flex flex-col gap-3">+ <ProfileNameInput+ ref={inputRef}+ testId="rename-profile-input"+ ruleTestId="rename-profile-rule"+ value={newName}+ onChange={handleNameChange}+ isRequired+ onKeyDown={(e) => {+ if (e.key === "Enter" && !renameProfile.isPending && isValid) {+ handleSubmit();+ }+ }}+ />+ </div>+ </ApiKeyModalBase>+ );+}diff --git a/src/components/features/settings/settings-input.tsx b/src/components/features/settings/settings-input.tsxindex ec9c80f16c..185bc77263 100644--- a/src/components/features/settings/settings-input.tsx+++ b/src/components/features/settings/settings-input.tsx@@ -1,3 +1,4 @@+import { forwardRef } from "react";import { cn } from "#/utils/utils";import { OptionalTag } from "./optional-tag";@@ -14,6 +15,7 @@ interface SettingsInputProps {startContent?: React.ReactNode;className?: string;onChange?: (value: string) => void;+ onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;required?: boolean;min?: number;max?: number;@@ -22,56 +24,72 @@ interface SettingsInputProps {/** Validation message shown when pattern doesn't match */title?: string;labelClassName?: string;+ /** ARIA describedby attribute for accessibility */+ ariaDescribedBy?: string;+ /** ARIA invalid attribute for accessibility */+ ariaInvalid?: boolean;}-export function SettingsInput({- testId,- name,- label,- type,- defaultValue,- value,- placeholder,- showOptionalTag,- isDisabled,- startContent,- className,- onChange,- required,- min,- max,- step,- pattern,- title,- labelClassName,-}: SettingsInputProps) {- return (- <label className={cn("flex flex-col gap-2.5 w-fit", className)}>- <div className="flex items-center gap-2">- {startContent}- <span className={cn("text-sm", labelClassName)}>{label}</span>- {showOptionalTag && <OptionalTag />}- </div>- <input- data-testid={testId}- onChange={(e) => onChange?.(e.target.value)}- name={name}- disabled={isDisabled}- type={type}- defaultValue={defaultValue}- value={value}- placeholder={placeholder}- min={min}- max={max}- step={step}- required={required}- pattern={pattern}- title={title}- className={cn(- "bg-tertiary border border-[#717888] h-10 w-full max-w-[680px] rounded-sm p-2 placeholder:italic placeholder:text-tertiary-alt",- "disabled:bg-[#2D2F36] disabled:border-[#2D2F36] disabled:cursor-not-allowed",- )}- />- </label>- );-}+export const SettingsInput = forwardRef<HTMLInputElement, SettingsInputProps>(+ function SettingsInput(+ {+ testId,+ name,+ label,+ type,+ defaultValue,+ value,+ placeholder,+ showOptionalTag,+ isDisabled,+ startContent,+ className,+ onChange,+ onKeyDown,+ required,+ min,+ max,+ step,+ pattern,+ title,+ labelClassName,+ ariaDescribedBy,+ ariaInvalid,+ },+ ref,+ ) {+ return (+ <label className={cn("flex flex-col gap-2.5 w-fit", className)}>+ <div className="flex items-center gap-2">+ {startContent}+ <span className={cn("text-sm", labelClassName)}>{label}</span>+ {showOptionalTag && <OptionalTag />}+ </div>+ <input+ ref={ref}+ data-testid={testId}+ onChange={(e) => onChange?.(e.target.value)}+ onKeyDown={onKeyDown}+ name={name}+ disabled={isDisabled}+ type={type}+ defaultValue={defaultValue}+ value={value}+ placeholder={placeholder}+ min={min}+ max={max}+ step={step}+ required={required}+ pattern={pattern}+ title={title}+ aria-describedby={ariaDescribedBy}+ aria-invalid={ariaInvalid}+ className={cn(+ "bg-tertiary border border-[#717888] h-10 w-full max-w-[680px] rounded-sm p-2 placeholder:italic placeholder:text-tertiary-alt",+ "disabled:bg-[#2D2F36] disabled:border-[#2D2F36] disabled:cursor-not-allowed",+ )}+ />+ </label>+ );+ },+);diff --git a/src/i18n/translation.json b/src/i18n/translation.jsonindex 87913d0282..9a2cdc3ac1 100644--- a/src/i18n/translation.json+++ b/src/i18n/translation.json@@ -24852,5 +24852,532 @@"ca": "S'està iniciant la conversa…","tr": "Sohbet başlatılıyor…","uk": "Розпочинаємо розмову…"+ },+ "ERROR$FAILED_TO_LOAD_PROFILE_TRY_AGAIN": {+ "en": "Failed to load existing profile. Please try again.",+ "ja": "既存のプロファイルの読み込みに失敗しました。もう一度お試しください。",+ "zh-CN": "无法加载现有配置文件。请重试。",+ "zh-TW": "無法載入現有設定檔。請重試。",+ "ko-KR": "기존 프로필을 로드하지 못했습니다. 다시 시도하세요.",+ "no": "Kunne ikke laste eksisterende profil. Vennligst prøv igjen.",+ "ar": "فشل في تحميل الملف الشخصي الحالي. يرجى المحاولة مرة أخرى.",+ "de": "Fehler beim Laden des vorhandenen Profils. Bitte versuchen Sie es erneut.",+ "fr": "Échec du chargement du profil existant. Veuillez réessayer.",+ "it": "Impossibile caricare il profilo esistente. Riprova.",+ "pt": "Falha ao carregar o perfil existente. Por favor, tente novamente.",+ "es": "Error al cargar el perfil existente. Por favor, inténtelo de nuevo.",+ "ca": "No s'ha pogut carregar el perfil existent. Torneu-ho a provar.",+ "tr": "Mevcut profil yüklenemedi. Lütfen tekrar deneyin.",+ "uk": "Не вдалося завантажити існуючий профіль. Будь ласка, спробуйте ще раз."+ },+ "SIDEBAR$INTEGRATIONS": {+ "en": "Integrations",+ "ja": "連携",+ "zh-CN": "集成",+ "zh-TW": "整合",+ "ko-KR": "통합",+ "no": "Integrasjoner",+ "ar": "التكاملات",+ "de": "Integrationen",+ "fr": "Intégrations",+ "it": "Integrazioni",+ "pt": "Integrações",+ "es": "Integraciones",+ "ca": "Integracions",+ "tr": "Entegrasyonlar",+ "uk": "Інтеграції"+ },+ "BACKEND$LOCAL_ROW": {+ "en": "Local",+ "ja": "ローカル",+ "zh-CN": "本地",+ "zh-TW": "本機",+ "ko-KR": "로컬",+ "no": "Lokal",+ "it": "Locale",+ "pt": "Local",+ "es": "Local",+ "ar": "محلي",+ "fr": "Local",+ "tr": "Yerel",+ "de": "Lokal",+ "uk": "Локальний",+ "ca": "Local"+ },+ "BUTTON$EDIT": {+ "en": "Edit",+ "ja": "編集",+ "zh-CN": "编辑",+ "zh-TW": "編輯",+ "ko-KR": "편집",+ "no": "Rediger",+ "it": "Modifica",+ "pt": "Editar",+ "es": "Editar",+ "ar": "تحرير",+ "fr": "Modifier",+ "tr": "Düzenle",+ "de": "Bearbeiten",+ "uk": "Редагувати",+ "ca": "Edita"+ },+ "SETTINGS$ADD_LLM_PROFILE": {+ "en": "Add LLM Profile",+ "ja": "LLMプロファイルを追加",+ "zh-CN": "添加LLM配置文件",+ "zh-TW": "新增LLM設定檔",+ "ko-KR": "LLM 프로필 추가",+ "no": "Legg til LLM-profil",+ "it": "Aggiungi profilo LLM",+ "pt": "Adicionar perfil LLM",+ "es": "Agregar perfil LLM",+ "ar": "إضافة ملف تعريف LLM",+ "fr": "Ajouter un profil LLM",+ "tr": "LLM Profili Ekle",+ "de": "LLM-Profil hinzufügen",+ "uk": "Додати профіль LLM",+ "ca": "Afegeix perfil LLM"+ },+ "SETTINGS$PROFILE_MENU": {+ "en": "Profile menu",+ "ja": "プロファイルメニュー",+ "zh-CN": "配置文件菜单",+ "zh-TW": "設定檔選單",+ "ko-KR": "프로필 메뉴",+ "no": "Profilmeny",+ "it": "Menu profilo",+ "pt": "Menu do perfil",+ "es": "Menú de perfil",+ "ar": "قائمة الملف الشخصي",+ "fr": "Menu du profil",+ "tr": "Profil menüsü",+ "de": "Profilmenü",+ "uk": "Меню профілю",+ "ca": "Menú del perfil"+ },+ "SETTINGS$PROFILE_API_KEY_SET": {+ "en": "API Key Set",+ "ja": "APIキー設定済み",+ "zh-CN": "API密钥已设置",+ "zh-TW": "API金鑰已設定",+ "ko-KR": "API 키 설정됨",+ "no": "API-nøkkel satt",+ "it": "Chiave API impostata",+ "pt": "Chave API definida",+ "es": "Clave API establecida",+ "ar": "تم تعيين مفتاح API",+ "fr": "Clé API définie",+ "tr": "API Anahtarı Ayarlandı",+ "de": "API-Schlüssel gesetzt",+ "uk": "API ключ встановлено",+ "ca": "Clau API establerta"+ },+ "SETTINGS$PROFILE_NAME_LABEL": {+ "en": "Profile Name",+ "ja": "プロファイル名",+ "zh-CN": "配置文件名称",+ "zh-TW": "設定檔名稱",+ "ko-KR": "프로필 이름",+ "no": "Profilnavn",+ "it": "Nome profilo",+ "pt": "Nome do perfil",+ "es": "Nombre del perfil",+ "ar": "اسم الملف الشخصي",+ "fr": "Nom du profil",+ "tr": "Profil Adı",+ "de": "Profilname",+ "uk": "Назва профілю",+ "ca": "Nom del perfil"+ },+ "SETTINGS$PROFILE_NAME_PLACEHOLDER": {+ "en": "Enter profile name",+ "ja": "プロファイル名を入力",+ "zh-CN": "输入配置文件名称",+ "zh-TW": "輸入設定檔名稱",+ "ko-KR": "프로필 이름 입력",+ "no": "Skriv inn profilnavn",+ "it": "Inserisci nome profilo",+ "pt": "Digite o nome do perfil",+ "es": "Ingrese el nombre del perfil",+ "ar": "أدخل اسم الملف الشخصي",+ "fr": "Entrez le nom du profil",+ "tr": "Profil adını girin",+ "de": "Profilname eingeben",+ "uk": "Введіть назву профілю",+ "ca": "Introdueix el nom del perfil"+ },+ "SETTINGS$PROFILE_NAME_RULE": {+ "en": "Profile name must start with a letter or digit, and contain only letters, digits, dots, underscores, or hyphens (max 64 characters)",+ "ja": "プロファイル名は文字または数字で始まり、文字、数字、ドット、アンダースコア、ハイフンのみを含める必要があります(最大64文字)",+ "zh-CN": "配置文件名必须以字母或数字开头,只能包含字母、数字、点、下划线或连字符(最多64个字符)",+ "zh-TW": "設定檔名稱必須以字母或數字開頭,只能包含字母、數字、點、底線或連字號(最多64個字元)",+ "ko-KR": "프로필 이름은 문자 또는 숫자로 시작해야 하며, 문자, 숫자, 점, 밑줄, 하이픈만 포함할 수 있습니다 (최대 64자)",+ "no": "Profilnavn må starte med en bokstav eller tall, og kan bare inneholde bokstaver, tall, punktum, understreker eller bindestreker (maks 64 tegn)",+ "it": "Il nome del profilo deve iniziare con una lettera o un numero e contenere solo lettere, numeri, punti, trattini bassi o trattini (massimo 64 caratteri)",+ "pt": "O nome do perfil deve começar com uma letra ou dígito e conter apenas letras, dígitos, pontos, sublinhados ou hífens (máximo de 64 caracteres)",+ "es": "El nombre del perfil debe comenzar con una letra o dígito, y contener solo letras, dígitos, puntos, guiones bajos o guiones (máximo 64 caracteres)",+ "ar": "يجب أن يبدأ اسم الملف الشخصي بحرف أو رقم، ويحتوي فقط على أحرف أو أرقام أو نقاط أو شرطات سفلية أو شرطات (64 حرفًا كحد أقصى)",+ "fr": "Le nom du profil doit commencer par une lettre ou un chiffre et ne contenir que des lettres, chiffres, points, tirets bas ou tirets (64 caractères maximum)",+ "tr": "Profil adı bir harf veya rakamla başlamalı ve yalnızca harf, rakam, nokta, alt çizgi veya tire içermelidir (en fazla 64 karakter)",+ "de": "Profilname muss mit einem Buchstaben oder einer Ziffer beginnen und darf nur Buchstaben, Ziffern, Punkte, Unterstriche oder Bindestriche enthalten (max. 64 Zeichen)",+ "uk": "Назва профілю повинна починатися з літери або цифри і містити лише літери, цифри, крапки, підкреслення або дефіси (макс. 64 символи)",+ "ca": "El nom del perfil ha de començar amb una lletra o dígit, i contenir només lletres, dígits, punts, guions baixos o guions (màxim 64 caràcters)"+ },+ "SETTINGS$PROFILE_RENAME_TITLE": {+ "en": "Rename Profile",+ "ja": "プロファイル名を変更",+ "zh-CN": "重命名配置文件",+ "zh-TW": "重新命名設定檔",+ "ko-KR": "프로필 이름 변경",+ "no": "Gi profilen nytt navn",+ "it": "Rinomina profilo",+ "pt": "Renomear perfil",+ "es": "Renombrar perfil",+ "ar": "إعادة تسمية الملف الشخصي",+ "fr": "Renommer le profil",+ "tr": "Profili Yeniden Adlandır",+ "de": "Profil umbenennen",+ "uk": "Перейменувати профіль",+ "ca": "Canvia el nom del perfil"+ },+ "SETTINGS$PROFILE_DELETE_TITLE": {+ "en": "Delete Profile",+ "ja": "プロファイルを削除",+ "zh-CN": "删除配置文件",+ "zh-TW": "刪除設定檔",+ "ko-KR": "프로필 삭제",+ "no": "Slett profil",+ "it": "Elimina profilo",+ "pt": "Excluir perfil",+ "es": "Eliminar perfil",+ "ar": "حذف الملف الشخصي",+ "fr": "Supprimer le profil",+ "tr": "Profili Sil",+ "de": "Profil löschen",+ "uk": "Видалити профіль",+ "ca": "Elimina el perfil"+ },+ "SETTINGS$PROFILE_DELETE_CONFIRMATION": {+ "en": "Are you sure you want to delete the profile \"{{name}}\"? This action cannot be undone.",+ "ja": "プロファイル\"{{name}}\"を削除してもよろしいですか?この操作は元に戻せません。",+ "zh-CN": "您确定要删除配置文件\"{{name}}\"吗?此操作无法撤消。",+ "zh-TW": "您確定要刪除設定檔\"{{name}}\"嗎?此操作無法復原。",+ "ko-KR": "프로필 \"{{name}}\"을(를) 삭제하시겠습니까? 이 작업은 취소할 수 없습니다.",+ "no": "Er du sikker på at du vil slette profilen \"{{name}}\"? Denne handlingen kan ikke angres.",+ "it": "Sei sicuro di voler eliminare il profilo \"{{name}}\"? Questa azione non può essere annullata.",+ "pt": "Tem certeza de que deseja excluir o perfil \"{{name}}\"? Esta ação não pode ser desfeita.",+ "es": "¿Está seguro de que desea eliminar el perfil \"{{name}}\"? Esta acción no se puede deshacer.",+ "ar": "هل أنت متأكد أنك تريد حذف الملف الشخصي \"{{name}}\"؟ لا يمكن التراجع عن هذا الإجراء.",+ "fr": "Êtes-vous sûr de vouloir supprimer le profil \"{{name}}\" ? Cette action ne peut pas être annulée.",+ "tr": "\"{{name}}\" profilini silmek istediğinizden emin misiniz? Bu işlem geri alınamaz.",+ "de": "Sind Sie sicher, dass Sie das Profil \"{{name}}\" löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.",+ "uk": "Ви впевнені, що хочете видалити профіль \"{{name}}\"? Цю дію не можна скасувати.",+ "ca": "Esteu segur que voleu eliminar el perfil \"{{name}}\"? Aquesta acció no es pot desfer."+ },+ "SETTINGS$PROFILE_DELETED": {+ "en": "Profile \"{{name}}\" deleted",+ "ja": "プロファイル「{{name}}」を削除しました",+ "zh-CN": "配置文件「{{name}}」已删除",+ "zh-TW": "設定檔「{{name}}」已刪除",+ "ko-KR": "프로필 \"{{name}}\" 삭제됨",+ "no": "Profilen \"{{name}}\" ble slettet",+ "it": "Profilo \"{{name}}\" eliminato",+ "pt": "Perfil \"{{name}}\" excluído",+ "es": "Perfil \"{{name}}\" eliminado",+ "ar": "تم حذف الملف الشخصي \"{{name}}\"",+ "fr": "Profil \"{{name}}\" supprimé",+ "tr": "\"{{name}}\" profili silindi",+ "de": "Profil \"{{name}}\" gelöscht",+ "uk": "Профіль \"{{name}}\" видалено",+ "ca": "Perfil \"{{name}}\" eliminat"+ },+ "SETTINGS$PROFILE_RENAMED": {+ "en": "Profile renamed to \"{{name}}\"",+ "ja": "プロファイル名を「{{name}}」に変更しました",+ "zh-CN": "配置文件已重命名为「{{name}}」",+ "zh-TW": "設定檔已重新命名為「{{name}}」",+ "ko-KR": "프로필 이름이 \"{{name}}\"(으)로 변경됨",+ "no": "Profilen ble omdøpt til \"{{name}}\"",+ "it": "Profilo rinominato in \"{{name}}\"",+ "pt": "Perfil renomeado para \"{{name}}\"",+ "es": "Perfil renombrado a \"{{name}}\"",+ "ar": "تمت إعادة تسمية الملف الشخصي إلى \"{{name}}\"",+ "fr": "Profil renommé en \"{{name}}\"",+ "tr": "Profil \"{{name}}\" olarak yeniden adlandırıldı",+ "de": "Profil umbenannt in \"{{name}}\"",+ "uk": "Профіль перейменовано на \"{{name}}\"",+ "ca": "Perfil reanomenat a \"{{name}}\""+ },+ "SETTINGS$PROFILES_LOAD_ERROR": {+ "en": "Failed to load profiles",+ "ja": "プロファイルの読み込みに失敗しました",+ "zh-CN": "加载配置文件失败",+ "zh-TW": "載入設定檔失敗",+ "ko-KR": "프로필 로드 실패",+ "no": "Kunne ikke laste profiler",+ "it": "Impossibile caricare i profili",+ "pt": "Falha ao carregar perfis",+ "es": "Error al cargar perfiles",+ "ar": "فشل في تحميل الملفات الشخصية",+ "fr": "Échec du chargement des profils",+ "tr": "Profiller yüklenemedi",+ "de": "Profile konnten nicht geladen werden",+ "uk": "Не вдалося завантажити профілі",+ "ca": "No s'han pogut carregar els perfils"+ },+ "SETTINGS$PROFILES_EMPTY": {+ "en": "No profiles saved yet. Add a profile to save your LLM configurations.",+ "ja": "まだプロファイルが保存されていません。LLM設定を保存するにはプロファイルを追加してください。",+ "zh-CN": "尚未保存任何配置文件。添加配置文件以保存您的LLM配置。",+ "zh-TW": "尚未儲存任何設定檔。新增設定檔以儲存您的LLM配置。",+ "ko-KR": "아직 저장된 프로필이 없습니다. LLM 구성을 저장하려면 프로필을 추가하세요.",+ "no": "Ingen profiler lagret ennå. Legg til en profil for å lagre LLM-konfigurasjonene dine.",+ "it": "Nessun profilo salvato. Aggiungi un profilo per salvare le tue configurazioni LLM.",+ "pt": "Nenhum perfil salvo ainda. Adicione um perfil para salvar suas configurações LLM.",+ "es": "Aún no hay perfiles guardados. Agregue un perfil para guardar sus configuraciones LLM.",+ "ar": "لم يتم حفظ أي ملفات شخصية بعد. أضف ملفًا شخصيًا لحفظ تكوينات LLM الخاصة بك.",+ "fr": "Aucun profil enregistré. Ajoutez un profil pour sauvegarder vos configurations LLM.",+ "tr": "Henüz kaydedilmiş profil yok. LLM yapılandırmalarınızı kaydetmek için bir profil ekleyin.",+ "de": "Noch keine Profile gespeichert. Fügen Sie ein Profil hinzu, um Ihre LLM-Konfigurationen zu speichern.",+ "uk": "Ще немає збережених профілів. Додайте профіль, щоб зберегти налаштування LLM.",+ "ca": "Encara no hi ha perfils desats. Afegiu un perfil per desar les vostres configuracions LLM."+ },+ "SETTINGS$BACK_TO_LLM_LIST": {+ "en": "Back to LLM profiles",+ "ja": "LLMプロファイル一覧に戻る",+ "zh-CN": "返回LLM配置文件列表",+ "zh-TW": "返回LLM設定檔列表",+ "ko-KR": "LLM 프로필 목록으로 돌아가기",+ "no": "Tilbake til LLM-profiler",+ "it": "Torna ai profili LLM",+ "pt": "Voltar aos perfis LLM",+ "es": "Volver a perfiles LLM",+ "ar": "العودة إلى ملفات تعريف LLM",+ "fr": "Retour aux profils LLM",+ "tr": "LLM profillerine geri dön",+ "de": "Zurück zu LLM-Profilen",+ "uk": "Повернутися до профілів LLM",+ "ca": "Torna als perfils LLM"+ },+ "SETTINGS$PROFILE_SAVED": {+ "en": "Profile \"{{name}}\" saved",+ "ja": "プロファイル「{{name}}」を保存しました",+ "zh-CN": "配置文件「{{name}}」已保存",+ "zh-TW": "設定檔「{{name}}」已儲存",+ "ko-KR": "프로필 \"{{name}}\" 저장됨",+ "no": "Profilen \"{{name}}\" ble lagret",+ "it": "Profilo \"{{name}}\" salvato",+ "pt": "Perfil \"{{name}}\" salvo",+ "es": "Perfil \"{{name}}\" guardado",+ "ar": "تم حفظ الملف الشخصي \"{{name}}\"",+ "fr": "Profil \"{{name}}\" enregistré",+ "tr": "\"{{name}}\" profili kaydedildi",+ "de": "Profil \"{{name}}\" gespeichert",+ "uk": "Профіль \"{{name}}\" збережено",+ "ca": "Perfil \"{{name}}\" desat"+ },+ "SETTINGS$PROFILE_LOADED": {+ "en": "Editing profile \"{{name}}\" - save to apply changes",+ "ja": "プロファイル「{{name}}」を編集中 - 変更を適用するには保存してください",+ "zh-CN": "正在编辑配置文件「{{name}}」- 保存以应用更改",+ "zh-TW": "正在編輯設定檔「{{name}}」- 儲存以套用變更",+ "ko-KR": "프로필 \"{{name}}\" 편집 중 - 변경 사항을 적용하려면 저장하세요",+ "no": "Redigerer profilen \"{{name}}\" - lagre for å bruke endringer",+ "it": "Modifica del profilo \"{{name}}\" - salva per applicare le modifiche",+ "pt": "Editando perfil \"{{name}}\" - salve para aplicar as alterações",+ "es": "Editando perfil \"{{name}}\" - guarda para aplicar los cambios",+ "ar": "جاري تحرير الملف الشخصي \"{{name}}\" - احفظ لتطبيق التغييرات",+ "fr": "Modification du profil \"{{name}}\" - enregistrez pour appliquer les modifications",+ "tr": "\"{{name}}\" profili düzenleniyor - değişiklikleri uygulamak için kaydedin",+ "de": "Profil \"{{name}}\" wird bearbeitet - zum Anwenden der Änderungen speichern",+ "uk": "Редагування профілю \"{{name}}\" - збережіть, щоб застосувати зміни",+ "ca": "Editant el perfil \"{{name}}\" - desa per aplicar els canvis"+ },+ "SETTINGS$PROFILE_SAVE_HINT": {+ "en": "Configure your LLM settings below, then click Save to create this profile.",+ "ja": "以下でLLM設定を構成し、「保存」をクリックしてこのプロファイルを作成します。",+ "zh-CN": "在下方配置您的LLM设置,然后点击保存以创建此配置文件。",+ "zh-TW": "在下方配置您的LLM設定,然後點擊儲存以建立此設定檔。",+ "ko-KR": "아래에서 LLM 설정을 구성한 다음 저장을 클릭하여 이 프로필을 만드세요.",+ "no": "Konfigurer LLM-innstillingene nedenfor, og klikk deretter Lagre for å opprette denne profilen.",+ "it": "Configura le impostazioni LLM di seguito, quindi fai clic su Salva per creare questo profilo.",+ "pt": "Configure suas configurações de LLM abaixo e clique em Salvar para criar este perfil.",+ "es": "Configura los ajustes de LLM a continuación y haz clic en Guardar para crear este perfil.",+ "ar": "قم بتكوين إعدادات LLM أدناه، ثم انقر فوق حفظ لإنشاء هذا الملف الشخصي.",+ "fr": "Configurez vos paramètres LLM ci-dessous, puis cliquez sur Enregistrer pour créer ce profil.",+ "tr": "Aşağıda LLM ayarlarınızı yapılandırın, ardından bu profili oluşturmak için Kaydet'e tıklayın.",+ "de": "Konfigurieren Sie unten Ihre LLM-Einstellungen und klicken Sie dann auf Speichern, um dieses Profil zu erstellen.",+ "uk": "Налаштуйте параметри LLM нижче, потім натисніть Зберегти, щоб створити цей профіль.",+ "ca": "Configura els paràmetres LLM a continuació i fes clic a Desa per crear aquest perfil."+ },+ "SETTINGS$AVAILABLE_PROFILES": {+ "en": "Available Models",+ "ja": "利用可能なモデル",+ "zh-CN": "可用模型",+ "zh-TW": "可用模型",+ "ko-KR": "사용 가능한 모델",+ "no": "Tilgjengelige modeller",+ "it": "Modelli disponibili",+ "pt": "Modelos disponíveis",+ "es": "Modelos disponibles",+ "ar": "النماذج المتاحة",+ "fr": "Modèles disponibles",+ "tr": "Mevcut Modeller",+ "de": "Verfügbare Modelle",+ "uk": "Доступні моделі",+ "ca": "Models disponibles"+ },+ "SETTINGS$EDIT_LLM_PROFILE": {+ "en": "Edit LLM Profile",+ "ja": "LLMプロファイルを編集",+ "zh-CN": "编辑LLM配置文件",+ "zh-TW": "編輯LLM設定檔",+ "ko-KR": "LLM 프로필 편집",+ "no": "Rediger LLM-profil",+ "it": "Modifica profilo LLM",+ "pt": "Editar perfil LLM",+ "es": "Editar perfil LLM",+ "ar": "تحرير ملف LLM الشخصي",+ "fr": "Modifier le profil LLM",+ "tr": "LLM Profilini Düzenle",+ "de": "LLM-Profil bearbeiten",+ "uk": "Редагувати профіль LLM",+ "ca": "Edita el perfil LLM"+ },+ "SETTINGS$PROFILE_NAME_AND_MODEL_REQUIRED": {+ "en": "Profile name and model are required",+ "ja": "プロファイル名とモデルは必須です",+ "zh-CN": "配置文件名称和模型是必需的",+ "zh-TW": "設定檔名稱和模型是必需的",+ "ko-KR": "프로필 이름과 모델이 필요합니다",+ "no": "Profilnavn og modell er påkrevd",+ "ar": "اسم الملف الشخصي والنموذج مطلوبان",+ "de": "Profilname und Modell sind erforderlich",+ "fr": "Le nom du profil et le modèle sont requis",+ "it": "Nome del profilo e modello sono obbligatori",+ "pt": "Nome do perfil e modelo são obrigatórios",+ "es": "El nombre del perfil y el modelo son obligatorios",+ "ca": "El nom del perfil i el model són obligatoris",+ "tr": "Profil adı ve model gereklidir",+ "uk": "Назва профілю та модель обов'язкові"+ },+ "SETTINGS$PROFILE_ACTIVATE": {+ "en": "Activate",+ "ja": "有効化",+ "zh-CN": "激活",+ "zh-TW": "啟用",+ "ko-KR": "활성화",+ "no": "Aktiver",+ "it": "Attiva",+ "pt": "Ativar",+ "es": "Activar",+ "ar": "تفعيل",+ "fr": "Activer",+ "tr": "Etkinleştir",+ "de": "Aktivieren",+ "uk": "Активувати",+ "ca": "Activa"+ },+ "SETTINGS$PROFILE_SET_ACTIVE": {+ "en": "Set as active",+ "ja": "アクティブに設定",+ "zh-CN": "设为活动",+ "zh-TW": "設為使用中",+ "ko-KR": "활성으로 설정",+ "no": "Sett som aktiv",+ "it": "Imposta come attivo",+ "pt": "Definir como ativo",+ "es": "Establecer como activo",+ "ar": "تعيين كنشط",+ "fr": "Définir comme actif",+ "tr": "Aktif olarak ayarla",+ "de": "Als aktiv festlegen",+ "uk": "Встановити як активний",+ "ca": "Establir com a actiu"+ },+ "SETTINGS$PROFILE_EDIT": {+ "en": "Edit",+ "ja": "編集",+ "zh-CN": "编辑",+ "zh-TW": "編輯",+ "ko-KR": "편집",+ "no": "Rediger",+ "it": "Modifica",+ "pt": "Editar",+ "es": "Editar",+ "ar": "تحرير",+ "fr": "Modifier",+ "tr": "Düzenle",+ "de": "Bearbeiten",+ "uk": "Редагувати",+ "ca": "Edita"+ },+ "SETTINGS$PROFILE_ACTIVATED": {+ "en": "Switched to profile \"{{name}}\"",+ "ja": "プロファイル「{{name}}」に切り替えました",+ "zh-CN": "已切换到配置文件「{{name}}」",+ "zh-TW": "已切換到設定檔「{{name}}」",+ "ko-KR": "프로필 \"{{name}}\"(으)로 전환됨",+ "no": "Byttet til profilen \"{{name}}\"",+ "it": "Passato al profilo \"{{name}}\"",+ "pt": "Alternado para o perfil \"{{name}}\"",+ "es": "Cambiado al perfil \"{{name}}\"",+ "ar": "تم التبديل إلى الملف الشخصي \"{{name}}\"",+ "fr": "Basculé vers le profil \"{{name}}\"",+ "tr": "\"{{name}}\" profiline geçildi",+ "de": "Zum Profil \"{{name}}\" gewechselt",+ "uk": "Перемкнено на профіль \"{{name}}\"",+ "ca": "Canviat al perfil \"{{name}}\""+ },+ "SETTINGS$PROFILE_ACTIVE": {+ "en": "Active",+ "ja": "有効",+ "zh-CN": "活动",+ "zh-TW": "啟用中",+ "ko-KR": "활성",+ "no": "Aktiv",+ "it": "Attivo",+ "pt": "Ativo",+ "es": "Activo",+ "ar": "نشط",+ "fr": "Actif",+ "tr": "Etkin",+ "de": "Aktiv",+ "uk": "Активний",+ "ca": "Actiu"+ },+ "SETTINGS$PROFILE_RENAME": {+ "en": "Rename",+ "ja": "名前を変更",+ "zh-CN": "重命名",+ "zh-TW": "重新命名",+ "ko-KR": "이름 바꾸기",+ "no": "Gi nytt navn",+ "it": "Rinomina",+ "pt": "Renomear",+ "es": "Renombrar",+ "ar": "إعادة تسمية",+ "fr": "Renommer",+ "tr": "Yeniden Adlandır",+ "de": "Umbenennen",+ "uk": "Перейменувати",+ "ca": "Reanomena"+ },+ "SETTINGS$PROFILE_DELETE": {+ "en": "Delete",+ "ja": "削除",+ "zh-CN": "删除",+ "zh-TW": "刪除",+ "ko-KR": "삭제",+ "no": "Slett",+ "it": "Elimina",+ "pt": "Excluir",+ "es": "Eliminar",+ "ar": "حذف",+ "fr": "Supprimer",+ "tr": "Sil",+ "de": "Löschen",+ "uk": "Видалити",+ "ca": "Suprimeix"}}