Skip to content

Commit 7a4e42f

Browse files
authored
Merge pull request #105 from yyyzl/fix/settings-ui-language-revert
fix: UI language reverts to English after a second save in Settings
2 parents 20d8d97 + 692137e commit 7a4e42f

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/components/settings/settings-view.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,15 @@ export function SettingsView() {
151151
)
152152

153153
// Resync draft from store if it changes out-of-band (e.g. project switch).
154+
// IMPORTANT: keep the current draft.uiLanguage instead of re-reading
155+
// `i18n.language`. handleSave calls multiple zustand setters before it
156+
// calls `i18n.changeLanguage` at the end, and each setter triggers this
157+
// effect mid-save — which used to clobber the user's pending language
158+
// pick with the still-stale `i18n.language`. The next save would then
159+
// see draft.uiLanguage out of sync with i18n.language and silently
160+
// revert the UI to the previous language.
154161
useEffect(() => {
155-
setDraftState(
162+
setDraftState((prev) =>
156163
initialDraft(
157164
llmConfig,
158165
searchApiConfig,
@@ -161,7 +168,7 @@ export function SettingsView() {
161168
outputLanguage,
162169
proxyConfig,
163170
maxHistoryMessages,
164-
i18n.language,
171+
prev.uiLanguage,
165172
),
166173
)
167174
}, [

0 commit comments

Comments
 (0)