Files
OpenHands/__tests__
0569bd77ec feat: add LLM profiles API layer and React Query hooks (#387)
* feat: add LLM profiles API layer and React Query hooks

This PR adds the foundational data layer for the LLM profiles feature:

## API Layer
- ProfilesService: Thin wrapper around SDK ProfilesClient with methods
  for list, get, save, delete, rename, and activate profile operations
- Re-exports SDK types for consumer convenience

## React Query Hooks
- useLlmProfiles: Query hook for listing all profiles
- useSaveLlmProfile: Mutation hook for creating/updating profiles
- useDeleteLlmProfile: Mutation hook for deleting profiles
- useRenameLlmProfile: Mutation hook for renaming profiles
- useActivateLlmProfile: Mutation hook for activating a profile

All mutation hooks properly invalidate both profile list and settings
caches on success, and disable global toasts (consumers handle errors).

## Utilities
- deriveProfileNameFromModel: Derives a clean profile name from model
  strings (e.g., 'openai/gpt-4' -> 'gpt-4')
- PROFILE_NAME_PATTERN: Validation regex for profile names

## Tests
- 47 tests covering all new functionality
- API service method tests
- Hook behavior tests (success, error handling, cache invalidation)
- Utility function tests

Part 1 of LLM Profiles feature (PR A from split plan).
No UI changes - this is purely a data layer addition.

Co-authored-by: openhands <openhands@all-hands.dev>

* fix: address PR review feedback

- Remove client.close() calls for consistency with other services
  (SettingsService, SecretsService don't call close())
- Use SETTINGS_QUERY_KEYS.personal() instead of .all for precision
- Add ActiveBackendProvider wrapper in useLlmProfiles tests
- Add test for query key including backend.id and orgId
- Add test for backend-switch cache isolation
- Fix truncation test to actually exercise trailing-dash removal
- Add test for model names that sanitize to empty string

Addresses review feedback from all-hands-bot.

Co-authored-by: openhands <openhands@all-hands.dev>

* chore: Remove PR-only artifacts

---------

Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: allhands-bot <allhands-bot@users.noreply.github.com>
2026-05-12 16:19:28 -04:00
..