Skip to content

LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。

TypeScript

fix: preserve draft uiLanguage across mid-save store updates

yyyzl692137edbedf
diff --git a/src/components/settings/settings-view.tsx b/src/components/settings/settings-view.tsx
index deb8689c..99d2f74a 100644
--- a/src/components/settings/settings-view.tsx
+++ b/src/components/settings/settings-view.tsx
@@ -151,8 +151,15 @@ export function SettingsView() {
)
// Resync draft from store if it changes out-of-band (e.g. project switch).
+ // IMPORTANT: keep the current draft.uiLanguage instead of re-reading
+ // `i18n.language`. handleSave calls multiple zustand setters before it
+ // calls `i18n.changeLanguage` at the end, and each setter triggers this
+ // effect mid-save — which used to clobber the user's pending language
+ // pick with the still-stale `i18n.language`. The next save would then
+ // see draft.uiLanguage out of sync with i18n.language and silently
+ // revert the UI to the previous language.
useEffect(() => {
- setDraftState(
+ setDraftState((prev) =>
initialDraft(
llmConfig,
searchApiConfig,
@@ -161,7 +168,7 @@ export function SettingsView() {
outputLanguage,
proxyConfig,
maxHistoryMessages,
- i18n.language,
+ prev.uiLanguage,
),
)
}, [