Conversation
Add default settings
There was a problem hiding this comment.
Pull request overview
This PR adds default settings functionality for user preferences, introducing new API endpoints to manage user preferences separately from full user settings. The implementation integrates with the model provider to automatically set the default selected_model to the first active model available.
Key Changes
- Added two new REST endpoints: GET and PATCH
/v1/users/me/settings/preferencesfor granular preference management - Implemented
DefaultPreferences()function to provide safe defaults for user preferences (enable_thinking, enable_search, enable_deep_research, enable_browser, selected_model) - Integrated
ModelProviderinterface with dependency injection to dynamically set default selected_model from the first active model
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/automation/auth-postman-scripts.json | Added comprehensive Postman test suite for user settings and preferences endpoints with test cases for guest and registered users |
| services/media-api/docs/swagger/swagger.json | CRITICAL: Changed payload types from object to integer array - appears to be unintended breaking change |
| services/llm-api/internal/interfaces/httpserver/routes/v1/users/users_route.go | Registered new GET/PATCH routes for preferences endpoints |
| services/llm-api/internal/interfaces/httpserver/routes/routes_provider.go | Added wire.Bind to bind ModelHandler as ModelProvider interface for dependency injection |
| services/llm-api/internal/interfaces/httpserver/handlers/usersettingshandler/user_settings_handler.go | Implemented GetPreferences and UpdatePreferences handlers with appropriate validation |
| services/llm-api/internal/interfaces/httpserver/handlers/modelhandler/model_handler.go | Added GetFirstActiveModelID method to retrieve default model for new users |
| services/llm-api/internal/domain/usersettings/user_settings.go | Added DefaultPreferences function, ModelProvider interface, and integrated model provider in NewService |
| services/llm-api/docs/swagger/*.{yaml,json,go} | Updated OpenAPI documentation with new conversation item types and preferences endpoints |
| services/llm-api/cmd/server/wire_gen.go | Updated wire dependency injection to pass modelHandler to usersettings.NewService |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "type": "array", | ||
| "items": { | ||
| "type": "integer" | ||
| } |
There was a problem hiding this comment.
The payload field type has been changed from an arbitrary JSON object to an array of integers. This is a breaking API change that could affect existing clients that send JSON objects in the payload field. The description mentions this field should contain "jan_* placeholders" which suggests it should remain as a flexible object type, not an integer array.
| "type": "array", | ||
| "items": { | ||
| "type": "integer" | ||
| } |
There was a problem hiding this comment.
The payload response type has been changed from an arbitrary JSON object to an array of integers. This is a breaking API change that could affect existing clients expecting resolved JSON objects with presigned URLs. The previous description indicated this field should contain "resolved payload with jan_* placeholders replaced by presigned URLs", which should be a flexible object type, not an integer array.
| } | ||
|
|
||
| // GetFirstActiveModelID returns the first model ID using the same logic as /v1/models endpoint. | ||
| // This is used to set the default selected_model in user preferences. |
There was a problem hiding this comment.
The function documentation should clarify what is returned when no models are available. Currently, the function returns an empty string and nil error when no models exist, but this behavior should be documented in the function comment to help callers understand they need to handle the empty string case.
| // This is used to set the default selected_model in user preferences. | |
| // This is used to set the default selected_model in user preferences. | |
| // If no active models are available, it returns an empty string and a nil error, and callers | |
| // should handle the empty string case as "no default model available". |
add default settings for exists users
Optimizing tool selection...Here are sample API calls for the User Settings and Preferences endpoints:
1. Fetch User Settings (Full)
Response:
{ "id": "550e8400-e29b-41d4-a716-446655440000", "user_id": "2fe14bff-e028-4519-95c6-06bf87512b9d", "base_style": "default", "preferences": { "enable_browser": false, "enable_deep_research": false, "enable_search": true, "enable_thinking": true, "selected_model": "unknown/jan-v2-30b" }, "created_at": "2025-12-18T04:16:25Z", "updated_at": "2025-12-18T04:16:25Z" }2. Fetch Preferences Only
Response:
{ "preferences": { "enable_browser": false, "enable_deep_research": false, "enable_search": true, "enable_thinking": true, "selected_model": "unknown/jan-v2-30b" } }3. Update Preferences Only
Response:
{ "preferences": { "enable_browser": false, "enable_deep_research": false, "enable_search": false, "enable_thinking": false, "selected_model": "unknown/jan-v2-8b" } }Summary Table
/v1/users/me/settingsGETbase_style+preferences)/v1/users/me/settingsPATCH/v1/users/me/settings/preferencesGET/v1/users/me/settings/preferencesPATCH