Uh oh!
There was an error while loading. Please reload this page.
fix(server): drop stale text generation options when resetting text-gen model selection - #2076
Merged
juliusmarminge merged 6 commits intoApr 16, 2026
Conversation
Loading
Uh oh!
There was an error while loading. Please reload this page.
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
Introduced applyServerSettingsPatch function in packages/shared/src/serverSettings.ts to handle server settings patches with atomic replacement for textGenerationModelSelection. When provider or model is updated in the patch, the entire textGenerationModelSelection object is rebuilt instead of deep-merged, ensuring stale nested options are dropped. Updated apps/server/src/serverSettings.ts and apps/web/src/hooks/useSettings.ts to use this new patch logic. Added comprehensive tests in packages/shared/src/serverSettings.test.ts and apps/server/src/serverSettings.test.ts to verify correct behavior.
Why
Previously, resetting the text generation model selection didn't work. Stale options from prior configurations would persist. The atomic replacement ensures clean resets while maintaining options when explicitly provided.
UI Changes
Checklist
Note
Low Risk
Small, targeted change to settings merge semantics plus tests; main risk is subtle behavior change for callers relying on old deep-merge of
textGenerationModelSelectionwhen updating provider/model.Overview
Fixes server settings patching so resetting
textGenerationModelSelectionno longer preserves stale nestedoptions. Introduces shared helperapplyServerSettingsPatchthat deep-merges normally but replacestextGenerationModelSelectionwhen a patch specifiesproviderand/ormodel, dropping omitted options.Both server-side
updateSettings(in-memory test layer and persisted path) and the web client’s optimistic settings update now use this helper, and new unit/integration tests cover replacement vs option-only merge behavior.Reviewed by Cursor Bugbot for commit 7d14771. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Drop stale
textGenerationModelSelectionoptions when resetting text-gen model selectionapplyServerSettingsPatchinpackages/shared/src/serverSettings.tsthat replacestextGenerationModelSelection(dropping staleoptions) whenproviderormodelare present in the patch, while still deep-merging when onlyoptionsare provided.deepMergewithapplyServerSettingsPatchin the server settings update handler and the test layer inapps/server/src/serverSettings.ts.apps/web/src/hooks/useSettings.tsso the UI stays consistent with server behavior.providerormodelin a settings patch now discards previously storedoptions; patches that only updateoptionscontinue to deep-merge as before.Macroscope summarized 7d14771.