Skip to content

Hot fix on settings reload#322

Merged
locnguyen1986 merged 3 commits intoreleasefrom
main
Dec 18, 2025
Merged

Hot fix on settings reload#322
locnguyen1986 merged 3 commits intoreleasefrom
main

Conversation

@locnguyen1986
Copy link
Collaborator

Hot fix on settings reload

Copilot AI review requested due to automatic review settings December 18, 2025 11:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an issue with settings reload by changing how user preferences are updated. Instead of replacing the entire Preferences map when an update request is received, the code now merges incoming preferences with existing ones.

Key Changes:

  • Modified the Apply method to merge preference updates instead of replacing the entire map
  • Added nil check and default initialization for preferences
  • Preserves existing preference values that are not included in the update request

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

s.Preferences = req.Preferences
// Merge preferences instead of replacing them
if s.Preferences == nil {
s.Preferences = DefaultPreferences()
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initializing with DefaultPreferences() when s.Preferences is nil may not be necessary here, since ensureDefaultPreferences() in the Service layer already handles merging defaults. Consider using an empty map instead (make(map[string]interface{})) to keep the Apply method focused solely on merging the request values without adding default initialization logic.

Suggested change
s.Preferences = DefaultPreferences()
s.Preferences = make(map[string]interface{})

Copilot uses AI. Check for mistakes.
Comment on lines 162 to 170
if req.Preferences != nil {
s.Preferences = req.Preferences
// Merge preferences instead of replacing them
if s.Preferences == nil {
s.Preferences = DefaultPreferences()
}
for key, value := range req.Preferences {
s.Preferences[key] = value
}
}
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change introduces inconsistent behavior in the Apply method. All other fields (MemoryConfig, ProfileSettings, AdvancedSettings) use full replacement semantics when non-nil, but Preferences now uses merge semantics. This inconsistency could be confusing for API consumers. Consider documenting this behavior difference in the method's comment or making the behavior consistent across all fields.

Copilot uses AI. Check for mistakes.
@locnguyen1986 locnguyen1986 merged commit 5f9335d into release Dec 18, 2025
14 checks passed
@github-project-automation github-project-automation bot moved this to QA in Jan Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: QA

Development

Successfully merging this pull request may close these issues.

4 participants